|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Sample HTML Report HTML Report Generator - Sample Application Screenshot IntroductionThe HTML Report Engine is a .NET class library which helps in generating well formatted HTML reports. It can take any BackgroundCrystal Reports is a reporting tool that comes along with VS.NET, but designing and deploying a Crystal Reports report in your application is a bit complex. Though this HTML report engine utility has only limited number of features, it can produce awesome reports with no complex designing and coding work involved. Using the codeIt’s a generic reporting utility which takes as a report source, a
The The The //Include the namespace
using HTMLReportEngine;
//Create report object and set properties.
Report report = new Report();
report.ReportTitle = "Issue Report";
//Create a DataSet ds and fill it before using this code.
report.ReportSource = ds;
//Create Section
Section release = new Section("Release","Release: ");
//Create SubSection
Section project = new Section("Project","ProjectID: ");
//Add the sections to the report
release.SubSection = project;
report.Sections.Add(release);
//Add report fields to the report object.
report.ReportFields.Add(new Field("TicketNo", "Ticket", 50, ALIGN.RIGHT));
report.ReportFields.Add(new Field("CreatedBy", "CreatedBy", 150));
report.ReportFields.Add(new Field("AssignedTo", "AssignedTo"));
report.ReportFields.Add(new Field("Release", "Release", 200));
report.ReportFields.Add(new Field("Project", "Project", 150, ALIGN.RIGHT));
//Generate and save the report
report.SaveReport(@"C:\Data\Report.htm");
Class properties and methods
Formatting the reportIncluding totalsThis report engine supports multiple SUM fields for a report. And the SUM can be displayed on demand in any of the sections added to the report. The SUM field must be of type numeric. The following code explains how to add SUM fields: //Add Total fields
report.TotalFields.Add("Project");
report.TotalFields.Add("ProgressedHours");
//Set IncludeTotal property of the sections to true
project.IncludeTotal = true;
release.IncludeTotal = true;
Adding chartsThis engine can produce bar charts. The developer has to provide only the //Set Chart properties
release.ChartChangeOnField = "Severity";
release.ChartValueField = "ProgressedHours";
release.ChartTitle = "Severity-Wise report";
release.ChartLabelHeader = "Severity Type";
release.ChartValueHeader = "Hours";
release.ChartPercentageHeader = "Progress";
Aligning fieldsField texts can be aligned to //Set field Alignment
Field field1 = new Field();
field1.Alignment = ALIGN.RIGHT;
Specifying colorsThe developers are allowed to change the background colors of section headers, column headers, and column data. Section headers can have gradient backgrounds by setting the //Specifying Colors
//Main Section header color
release.BackColor = Color.WhiteSmoke;
release.GradientBackground = true;
//Sub Section header color
project.BackColor = Color.GhostWhite;
project.GradientBackground = true;
//Field Colors
field1.HeaderBackColor = Color.LightSlateGray;
field1.BackColor = Color.Gainsboro;
field2.HeaderBackColor = Color.LightSlateGray;
field2.BackColor = Color.White;
field3.HeaderBackColor = Color.LightSlateGray;
field3.BackColor = Color.Gainsboro;
Points of interestIt is recommended that you specify the column width for all report fields except one. That one may be a variable text field. The field without column width will automatically fit into the remaining space available in the table. There is a simple way to export data to MS Excel. You can open the generated HTML file in Internet Explorer, right click on the report, and select 'Export to Excel'. Done! History
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||