Demo如附件:
核心代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- SectionReport1 sr = new SectionReport1();
- sr.Document.Printer.PrinterName = "";
- DataTable dt = new DataTable();
- dt.Columns.Add("Col1");
- dt.Columns.Add("Col2");
- dt.Columns.Add("Col3");
- dt.Rows.Add("1","2","3");
- dt.Rows.Add("2","2","2");
- dt.Rows.Add("3", "3", "3");
- sr.DataSource = dt;
- float count = dt.Rows.Count * 2;
- sr.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom;
- sr.PageSettings.PaperHeight = count;
- sr.PageSettings.PaperWidth = 4.0f;
- viewer1.LoadDocument(sr);
- }
复制代码
|