Getting started with Icebear reports - PascalDeclercq1964/Icebear GitHub Wiki

The simplest report

To create a very basic report use the following code:

Report report = new Report(); 
report.DataSource = myData;  

use a IEnumerable of a strongly typed object as datasource

report.AddField("FieldName", width);  
report.AddField("FieldName", width, HeaderLabel:"Field Label"); 

adds a field to the detail starting at the left margin and a second field, 3 pixels to the right of the previous field. The second field will have a label in the pageheader section a the same horizontal position

report.GeneratePDF($"c:\\temp\\Report {DateTime.Now:yyyyMMddhhmmss}.pdf");   

Generate the report to a PDF

report.Print(WindowsPrinterName);

Or print it to a printer of your choice.

Some extra control parameters in the AddField method

  • Aligment : Left, Center, Right or justify
  • Mask : formatting numbers or date. Use the .net formatstring

Examples:

report.AddField("UnitPrice", 60, HeaderLabel: "Unit price", Alignment: Alignment.Right, Mask: "0.00"); 
report.AddField("UnitsInStock", 60, HeaderLabel: "Stock qty", Alignment: Alignment.Right); 
report.AddField("UnitsOnOrder", 60, HeaderLabel: "On order qty", Alignment: Alignment.Right, Mask: "#"); 

Next step

Make the page a bit more fancy