XML主要用来描述打印报表的名称,数据来源,格式,分页打印等信息,具体标签可自己定义,下面是笔者针对会员管理系统报表打印所制定的XML文档:
Memberlist.xml
〈xml version="1.0" encoding="utf-8" >
〈XmlReport>
〈Page>
〈Title>Member information〈/Title>
〈ApplyXSLT>〈/ApplyXSLT>
〈/Page>
〈Report>
〈Title>Member list〈/Title>
〈TableName>Memberlist〈/TableName>
〈SQLdataConnection>Data Source=localhost;User ID=sa;password=;Initial Catalog=XMLReport;〈/SQLdataConnection>
〈OleDbConnection>〈/OleDbConnection>
〈Sql>Select MemberID, prefix+'. '+ firstname+' '+ surname AS [Member Name],CityOrTown,State,PostCode, '$'+convert(varchar(12),FeesPaid) As Fees From Members;〈/Sql>
〈PageSize>10〈/PageSize>
〈/Report>
〈Report>
〈Title>Member Summary〈/Title>
〈TableName>MemberSummary〈/TableName>
〈SQLdataConnection>Data Source=localhost;User ID=sa;password=;Initial Catalog=XMLReport;〈/SQLdataConnection>
〈OleDbConnection>〈/OleDbConnection>
〈Sql>Select Count(MemberID) As [Member Count], '$'+convert(varchar(12),Sum(FeesPaid)) As [Fees Total] From Members;〈/Sql>
〈PageSize>〈/PageSize>
〈/Report>
〈/XmlReport>
标签说明:
Page Title:报表标题
ApplyXSLT:应用样式表定制报表
SQLdaraConnection: 数据源连接字串,数据提供者为SQL server
OleDbConnection:数据源连接字串,数据提供者为OleDb
Sql:选取报表数据的sql语句
PageSize:分页打印,每页显示的记录条数
读者还可以自定义一些更精