Bitnova Reports - a lightweight C# WinForms library designed to help you create, customize, and export HTML-based reports with ease.
On Sale
$9.00
$9.00
Bitnova Reports is a lightweight C# WinForms library designed to help you create, customize, and export HTML-based reports with ease. It supports embedding images, tables, charts, formatted text, lists, and automatic integration with form controls.
Overview
With BitnovaReports, you can:
- Construct reports using an intuitive, chainable builder pattern.
- Include headers, styled text, tables from DataGridView, charts with multiple series, images, lists, page breaks, and footers.
- Automatically pull content from WinForms controls like PictureBox, DataGridView, and Chart.
- Preview reports in a modal window with a toolbar for saving to PDF, exporting to HTML, printing, and dynamically adjusting fonts.
- Export to PDF with iText (defaulting to A4, with customizable page sizes) or as raw HTML.
- Enhance user experience with a loading overlay during save operations.
The library generates self-contained HTML with embedded base64-encoded images and charts, ensuring your reports are portable and ready to share.
Key Features:
- Fluent API chaining (e.g., .AddHeader().AddText().AddTable()).
- Customizable global styling options.
- Interactive preview with a feature-rich toolbar.
- Multi-page report support with page breaks.
- Dynamic font adjustments in the preview interface to avoid assembly conflicts.
Installation
To get started with Bitnova Reports in your project:
- Set Up Your Environment: Ensure your project targets .NET Framework 4.8 (or .NET 6+ with System.Drawing.Common) and uses WinForms.
- Install Required Packages: Add the following NuGet packages to your project:
- Microsoft.Windows.Compatibility (for WinForms and charting support).
- System.Windows.Forms.DataVisualization (for chart functionality).
- itext7 (version 7.2.5 or a compatible version).
- itext7.pdfhtml (for HTML-to-PDF conversion).
- itext7.bouncy-castle-adapter (to handle PDF encryption requirements).
- You can install these packages using the NuGet Package Manager in Visual Studio or the Package Manager Console with commands like:
- text
- Install-Package itext7
- Install-Package itext7.pdfhtml
- Install-Package itext7.bouncy-castle-adapter
- Add BitnovaReports: Include the BitnovaReports library in your project by referencing the provided package or assembly (consult your package manager or project documentation for details).
- Project References: Verify that your project includes references to System.Windows.Forms, System.Drawing, and System.Data.
Core Concepts
- Fluent Builder Pattern: Chain methods to build your report step-by-step, with each method returning the builder instance for further calls.
- HTML Generation: Reports are constructed as HTML strings, with images and charts embedded as base64 data for portability.
- Preview Interface: A modal Form with an embedded WebBrowser control provides an interactive preview, complete with a toolbar.
- PDF Export: Leverages iText to convert HTML to PDF, supporting A4 as the default page size with optional customization.
- Form Integration: The AddForm method automatically detects and includes supported controls from a specified Form.
- Styling: Apply global styles via the SetStyle method, and adjust fonts dynamically in the preview using CSS injection.
- Loading Overlay: A semi-transparent panel appears during save operations to indicate progress.
API Reference
Classes
- ChartSeriesData: A data structure for defining chart series.
- Properties:
- Name (string): The series name (optional, defaults to "SeriesX").
- Labels (List<string>): Labels for data points (e.g., months).
- Values (List<double>): Numerical values for the series.
- ChartType (SeriesChartType): Chart type (e.g., Line, Column, Bar; defaults to Line).
- ReportStyle: Configures the global appearance of the report.
- Properties:
- FontFamily (string, default "Segoe UI"): Font family for text.
- FontSize (int, default 12): Base font size in pixels.
- FontColor (string, default "#222"): Text color in hex.
- HeaderColor (string, default "#444"): Header text color.
- TableBorderColor (string, default "#ccc"): Table border color.
- TableHeaderBg (string, default "#f4f4f4"): Table header background color.
ReportBuilder Methods
- ReportBuilder(): Creates a new report builder instance, initializing the HTML structure.
- SetStyle(Action<ReportStyle> config): Applies global styling options before adding content.
- Example: .SetStyle(s => s.FontFamily = "Arial").
- AddHeader(string title, string subtitle, PictureBox logo = null): Adds a header section with an optional logo image.
- AddImage(PictureBox pb): Embeds an image from a PictureBox as a base64-encoded PNG.
- AddText(string text, bool bold = false, bool italic = false, int fontSize = 0, string color = ""): Adds a paragraph with optional formatting.
- AddTable(DataGridView grid): Converts a DataGridView into an HTML table.
- AddChart(string title, IEnumerable<ChartSeriesData> seriesData, int width = 600, int height = 300): Generates a chart as a PNG image and embeds it.
- Note: All series in a single call must use compatible chart types (e.g., Column and Line; avoid mixing Bar and Pie).
- AddForm(Form form): Automatically includes supported controls (e.g., PictureBox, DataGridView, Chart) from the specified form.
- AddList(IEnumerable<string> items, bool ordered = false): Creates an ordered (ol) or unordered (ul) list.
- AddPageBreak(): Inserts a page break for multi-page PDF layouts.
- AddFooter(string text): Adds a centered footer at the bottom of the report.
- GetHtml(): Returns the complete HTML string of the report.
- ShowPreview(string title = "Report Preview"): Displays the report in a preview window with a toolbar.
- SaveToPdf(string filePath, PageSize pageSize = null): Exports the report to a PDF file (defaults to A4 size).
Preview Toolbar Features
- 💾 Save to PDF: Opens a file dialog to save the report as a PDF.
- 🖨 Print: Launches a print dialog to print the report.
- 🖋 Font Settings: Opens a font dialog to dynamically change font family, size, and color in the preview.
- 📄 Export to HTML: Saves the raw HTML to a file.
- Loader: Displays a "Saving... Please wait" overlay during PDF or HTML exports.