Click here to Skip to main content
15,882,063 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 439K   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 ReportTest5 : IReportMaker
	{

        public void MakeDocument(ReportDocument reportDocument)
        {
            TextStyle.ResetStyles();

            ReportBuilder builder = new ReportBuilder(reportDocument);
			builder.StartDocumentLayout();
            
            builder.AddTextSection(MainForm.Text1);
            //TextStyle.Normal.MarginTop = 0.05f;
			builder.AddTextSection("a ");
			builder.AddTextSection("bold", TextStyle.BoldStyle);
			builder.AddTextSection(" word followed by one that is ");
			builder.AddTextSection("underlined", TextStyle.UnderlineStyle);
			TextStyle colorStyle = new TextStyle(TextStyle.Normal);
			colorStyle.Brush = Brushes.RoyalBlue;
			builder.AddTextSection("And we can even make text that is colored.", colorStyle);
			builder.AddTextSection("And we can make text that is normal.");
			builder.AddTextSection("And we can again make text that is colored.", colorStyle);

            
            builder.AddTextSection ("More words", TextStyle.Heading1);
            TextStyle.Heading1.SizeDelta += 10;
            builder.CurrentSection.VerticalAlignment = VerticalAlignment.Bottom;
            builder.AddTextSection (" other");
            builder.CurrentSection.VerticalAlignment = VerticalAlignment.Bottom;
            //builder.AddTextSection ("\nMore words");

			builder.FinishDocumentLayout();


        }



	}
}

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