ASP.NET中应用XML技术实现Web报表打印__教程 |
|
日期:2007-5-20 1:25:47 人气:78 [大 中 小] |
|
|
|
labelPageTitle.Text = dtPage.Rows[0]["Title"].ToString();
for(int i = 0;i < dtReport.Rows.Count; i++)
{
GetLabel(i).Text = dtReport.Rows[i]["Title"].ToString();
if(dtReport.Rows[i]["SQLdataConnection"].ToString() != String.Empty || dtReport.Rows[i]["Sql"].ToString() != String.Empty || dtReport.Rows[i]["OleDbConnection"].ToString() != String.Empty)
{
DataGrid dg = GetDataGrid(i);
if(dtReport.Rows[i]["PageSize"].ToString() != String.Empty)
{
//分页打印
dg.AllowPaging = true;
dg.PagerStyle.Mode = PagerMode.NumericPages;
dg.PagerStyle.PageButtonCount = 10;
dg.PageSize = Convert.ToInt32(dtReport.Rows[i]["PageSize"].ToString());
}
DataSet ds = new DataSet();
//从Report.xml读取数据源信息
if(dtReport.Rows[i]["SQLdataConnection"].ToString() != String.Empty)
{
//数据提供者为SQL Server
SqlConnection Conn = new SqlConnection(dtReport.Rows[i]["SQLdataConnection"].ToString());
SqlDataAdapter myDataAdapt = new SqlDataAdapter(dtReport.Rows[i]["Sql"].ToString(),Conn);
myDataAdapt.Fill(ds,dtReport.Rows[i]["TableName"].ToString());
}
else if(dtReport.Rows[i]["OleDbConnection"].ToString() != String.Empty)
{
//数据提供者为OLE DB
OleDbConnection Conn = new OleDbConnection(dtReport.Rows[i]["OleDbConnection"].ToString());
OleDbDataAdapter myDataAdapt = new OleDbDataAdapter(dtReport.Rows[i]["Sql"].ToString(),Conn);
myDataAdapt.Fill(ds,dtReport.Rows[i]["TableName"].ToString());
}
//用通用页面显示报表
dg.DataSource = ds;
dg.DataBind();
}
}
}
catch
{
labelPageTitle.Text = "The requested report could not be found";
}
}
3.3 创建定制打印页面
需要在XML文档ApplyXSLT标签内添加对应的xslt文件名,并制作相应的样式表放在项目的xslt文件夹下即可。如下代码添加到通用打印程序中。
if(dtPage.Rows[0]["ApplyXSLT"].ToString() != string.Empty ) |
|
出处:本站原创 作者:佚名 |
|
|