Click here to Skip to main content
15,881,794 members
Articles / Programming Languages / Visual Basic

Printing Reports in .NET

Rate me:
Please Sign up or sign in to vote.
4.85/5 (70 votes)
26 Aug 2008CPOL11 min read 438.9K   15.6K   257  
Using the library presented, you can print reports from C# and other .NET languages
using System;
using System.Data;
using System.Drawing;
using ReportPrinting;

namespace ReportDocumentTesting
{
	/// <summary>
	/// Document structure (a horizontal layout within a vertical layout).
	/// </summary>
	public class ReportTest9 : IReportMaker
	{
        public void MakeDocument(ReportDocument reportDocument)
        {
            TextStyle.ResetStyles();
            reportDocument.DefaultPageSettings.Margins.Top = 75;
            reportDocument.DefaultPageSettings.Margins.Bottom = 75;
            TextStyle small = new TextStyle (TextStyle.Normal);
            small.Size = 9;

            ReportBuilder builder = new ReportBuilder(reportDocument);
            builder.AddPageHeader ("Header", HorizontalAlignment.Center);
            builder.AddPageFooter ("Page %p", String.Empty, "Footer");
            builder.AddPageHeaderLine ();
            builder.AddPageFooterLine ();

            builder.StartColumnLayout (2, 0.1f);
            
            builder.AddTextSection (MainForm.Text2, small);
            
            DataView dv1 = SampleReportMaker1.GetDataView();
            builder.AddDataSection (dv1, false, 2.0f, true, true);
            builder.CurrentSection.MarginTop = 0.2f;
            builder.CurrentSection.MarginBottom = 0.2f;

            builder.AddPageBreak();
            builder.AddTextSection ("Text for new page");
            builder.AddColumnBreak();
            builder.AddTextSection ("Text for a new column");
            builder.AddColumnBreak();
            builder.AddTextSection ("Text for another column which should also be a new page");

            builder.FinishColumnLayout ();


        }



	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions