通用表格打印 示例
2012-10-03 20:44
155 查看
//本示例需要通用表格打印1或2,以及接口和Code128条码生成一起使用
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cyh.General;
namespace DemoTableXReport
{
public partial class Form1 : Form
{
private DataSet dataSet1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//读入数据到dataSet
dataSet1 = new DataSet();
dataSet1.ReadXml(Application.StartupPath+ "\\testReport.xml", System.Data.XmlReadMode.ReadSchema);
dataGridView1.DataSource = dataSet1;
dataGridView1.DataMember = dataSet1.Tables[0].TableName;
}
private void button1_Click(object sender, EventArgs e)
{
iTableReport xtr = new ctlTableReport();
xtr.AddReportTitle("测试上1(center)", true, null, StringAlignment.Center, Size.Empty);
xtr.AddReportTitle("测试上2(far)", true, null, StringAlignment.Far, Size.Empty);
xtr.AddReportTitle("测试下1(center)", false, null, StringAlignment.Center, Size.Empty);
xtr.AddReportTitle("测试下2(near){0}", false);
xtr.AddReportField("编 号", null, "药品目录", StringAlignment.Near, null, false, string.Empty, true, string.Empty, Size.Empty);
xtr.AddReportField("名 称", "名称");
xtr.AddReportField("规 格2", null, "规格", StringAlignment.Near, null, false, "合计", false, string.Empty, Size.Empty);
xtr.AddReportField("零 售 价3", null, "零售价", StringAlignment.Far, null, false, "", true, "{0:#0.00}", Size.Empty);
xtr.SetReportBarCode("A202010", new Point(100, 0), new Size(500, 100), true, string.Empty);
//int r = xtr.GetAutoRow(dataSet1.Tables[0].Rows.Count, 40);
//xtr.SetReportMain(100, r, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", true, 1);
xtr.SetReportMain(100, 20, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", false , 1);
xtr.UnitAfterPrint += new ReportUnitAfterPrint(xtr_UnitAfterPrint);
xtr.DataSource = dataSet1.Tables[0];
xtr.ShowDialog();
}
void xtr_UnitAfterPrint(object sender, ReportBandType source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
{
//if (source == ReportBandType.PageFooder)
// Value = string.Format("{0}",PageIndex+1);
//throw new NotImplementedException();
}
void xtr_UnitAfterPrint(object sender, int source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
{
//在此可以校正打印的内容和格式
}
}
}
sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cyh.General;
namespace DemoTableXReport
{
public partial class Form1 : Form
{
private DataSet dataSet1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//读入数据到dataSet
dataSet1 = new DataSet();
dataSet1.ReadXml(Application.StartupPath+ "\\testReport.xml", System.Data.XmlReadMode.ReadSchema);
dataGridView1.DataSource = dataSet1;
dataGridView1.DataMember = dataSet1.Tables[0].TableName;
}
private void button1_Click(object sender, EventArgs e)
{
iTableReport xtr = new ctlTableReport();
xtr.AddReportTitle("测试上1(center)", true, null, StringAlignment.Center, Size.Empty);
xtr.AddReportTitle("测试上2(far)", true, null, StringAlignment.Far, Size.Empty);
xtr.AddReportTitle("测试下1(center)", false, null, StringAlignment.Center, Size.Empty);
xtr.AddReportTitle("测试下2(near){0}", false);
xtr.AddReportField("编 号", null, "药品目录", StringAlignment.Near, null, false, string.Empty, true, string.Empty, Size.Empty);
xtr.AddReportField("名 称", "名称");
xtr.AddReportField("规 格2", null, "规格", StringAlignment.Near, null, false, "合计", false, string.Empty, Size.Empty);
xtr.AddReportField("零 售 价3", null, "零售价", StringAlignment.Far, null, false, "", true, "{0:#0.00}", Size.Empty);
xtr.SetReportBarCode("A202010", new Point(100, 0), new Size(500, 100), true, string.Empty);
//int r = xtr.GetAutoRow(dataSet1.Tables[0].Rows.Count, 40);
//xtr.SetReportMain(100, r, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", true, 1);
xtr.SetReportMain(100, 20, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", false , 1);
xtr.UnitAfterPrint += new ReportUnitAfterPrint(xtr_UnitAfterPrint);
xtr.DataSource = dataSet1.Tables[0];
xtr.ShowDialog();
}
void xtr_UnitAfterPrint(object sender, ReportBandType source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
{
//if (source == ReportBandType.PageFooder)
// Value = string.Format("{0}",PageIndex+1);
//throw new NotImplementedException();
}
void xtr_UnitAfterPrint(object sender, int source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
{
//在此可以校正打印的内容和格式
}
}
}
相关文章推荐
- 通用表格打印 示例
- 通用表格打印1
- 通用表格打印2 (基于DevExpress)
- 通用表格打印2 (基于DevExpress)
- 通用表格打印1
- C# 通用表格打印 (接口)
- 03.LoT.UI 前后台通用框架分解系列之——多样的表格
- Linux下通用打印系统CUPS使用教程
- EXCEL打印出表格的形式
- Vue.js实现的表格增加删除demo示例
- JSP-打印动态表格
- 关于Qt下如何获取屏幕尺寸以及打印的代码示例
- 第七章 业务数据库的管理(九)-- 打印表格行
- 通用对话框专题之打印和页面设置对话框
- Qt5打印功能示例代码
- MySql数据库查询结果用表格输出PHP代码示例
- CSS控制图片、表格、背景颜色渐变示例
- jQuery实现的简单动态添加、删除表格功能示例
- vb.net下打印清单示例(连续纸和固定纸张打印)
- JAVA中通用JPEG缩影图Bean的制作与示例