RdlcRptGenLite – Automatic RDLC report in C# directly from a DataTable
You’ll download a ZIP file containing the source code (
RdlcRptGenLite.cs), a demo form, and a Danish guide. The class is free to use and distribute under the MIT license.
RdlcRptGenLite is an enhanced, simplified version of the popular (but now discontinued) RdlcRptGen project. The class is written in C# and lets you generate a fully working RDLC report directly from a DataTable—without using Visual Studio’s report designer. You can display the report in a ReportViewer with just one line of code.
By using RdlcRptGenLite, you don’t have to configure the report layout ahead of time—the class automatically builds the RDLC XML report definition based on your DataTable structure and displays the report immediately.
Features and use cases
- Generate RDLC reports dynamically: From the columns and rows in a
DataTable. - Brugervenlig integration: Kan bruges with a single line of code:
new RdlcRptGenLite(myDataTable).DisplayReport(); - Display via ReportViewer: Supports the standard
ReportViewercontrol in Windows Forms. - Configurable elements: Beyond the default view, you can set additional properties such as report title, font, table colors, and page setup.
Example usage
RdlcRptGenLitereport = newRdlcRptGenLite(myDataTable);
report.ReportTitle = "Q2 Sales";
report.FontName = "Segoe UI";
report.DisplayReport(); // Displays the report in a standard ReportViewer form
Benefits for developers
RdlcRptGenLite is ideal for developers working with business data, back-office reports, analytics, or admin systems where dynamic reports need to be generated quickly and easily—without heavy integrations or an external report designer.
You’ll download a ZIP file containing the source code (
RdlcRptGenLite.cs), a demo form, and a Danish guide. The class is free to use and distribute under the MIT license.
Top 5 tips for RdlcRptGenLite
Start with a simple DataTable
RdlcRptGenLite works best with a simple, flat structure. Avoid complex types like nested objects, DataRelation dependencies, or specialized classes. Instead, use standard columns with string, int, decimal, DateTime, etc. This ensures error-free generation of the internal RDLC XML and a clean tabular layout in the viewer.
Tip: You can adjust column captions via
DataTable.Columns[i].ColumnNameto produce clearer headers in the report.
Customize the report design
RdlcRptGenLite supports several helpful properties that let you style the report without manually editing an RDLC file:
ReportTitle: Adds a heading at the top of the report.FontName: Switch to, for example, Segoe UI, Verdana, or your preferred font.TableHeaderBackColor: Change the background color of column headers.PageOrientation: Choose between portrait or landscape layout.
Tip: Kombinér flere egenskaber for at matche your company’s visual identity.
Use with ReportViewer in Windows Forms
To display the report correctly, make sure Microsoft.ReportViewer.WinForms is installed via NuGet or as a reference. RdlcRptGenLite opens a new form with ReportViewer and shows the report automatically—no extra GUI code required.
Tip: If you’re targeting .NET Framework 4.7 or later, ensure you use a compatible version of ReportViewer.
Save the report as XML
Want to persist the dynamically generated report as an RDLC file for later use or editing? Use:
string rdlcXml = report.GetRdlcXml();File.WriteAllText("MyReport.rdlc", rdlcXml);It’s an effective way to convert runtime reports into reusable design files.
Tip: Du kan åbne den gemte .rdlc-fil i Visual Studio og fine-tune the layout visually if needed.
Combine with DataSets for advanced functionality
Although RdlcRptGenLite uses a DataTable as the primary input, you can take tables from a DataSet and pass them along:
newRdlcRptGenLite(myDataSet.Tables["OrderData"]).DisplayReport();
This lets you work with multiple data sources while keeping the API simple.
Tip: Consider a wrapper method that picks the relevant tables automatically based on user input or business logic.



