DataSet取得了数据,但是跑出来的PDF文件却没有内容,真是奇怪!
//设置数据源和报表格式
ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(Server.MapPath("R1119.rpt"));
DataSet dsrpt=new DataSet();
dsrpt = getRptDs(TxbNo.Text.Trim());//取得数据
reportDoc.SetDataSource(dsrpt);
//生成文件
string fileUrl = "";
DiskFileDestinationOptions objFile = new DiskFileDestinationOptions();
ExportOptions objExport = reportDoc.ExportOptions;
objExport.ExportDestinationOptions = objFile;
objExport.ExportDestinationType = ExportDestinationType.DiskFile;
switch (fileType)
{
case "Pdf":
Response.ContentType = "application/pdf";
objExport.ExportFormatType = ExportFormatType.PortableDocFormat;
objFile.DiskFileName = Server.MapPath("~/SCFOLDER/PRINT/R1119.pdf");
fileUrl = "~/SCFOLDER/PRINT/R1119.pdf";
break;
case "Doc":
Response.ContentType = "application/ms-excel";
objExport.ExportFormatType = ExportFormatType.WordForWindows ;
objFile.DiskFileName = Server.MapPath("~/SCFOLDER/PRINT/R1119.doc");
fileUrl = "~/SCFOLDER/PRINT/R1119.doc";
break;
case "Xls":
Response.ContentType = "application/vnd.ms-excel";
objExport.ExportFormatType = ExportFormatType.Excel;
objFile.DiskFileName = Server.MapPath("~/SCFOLDER/PRINT/R1119.xls");
fileUrl = "~/SCFOLDER/PRINT/R1119.xls";
break;
}
reportDoc.Export();
Response.Redirect(fileUrl);
/// <summary>
/// 取得报表的数据
/// </summary>
/// <param name="no">单号</param>
/// <returns></returns>
private DataSet getRptDs(string no)
{
DS1119 ds = new DS1119();
string taskSql = "select task_sno,task_no,task_appco,task_appdpt,task_type,task_appdt,task_appman,task_status,task_expdt,task_respco,task_respdpt,task_respman,task_chkman,task_chkdt,task_aptdt,task_rejdt,task_hitrate,task_cfmman,task_cfmdt,task_topic,task_content,task_att1fname,task_att1url,task_att1uptime,task_att2fname,task_att2url,task_att2uptime from task where task_no='" + no + "'";
string tasksSql = "select tasks_sno,tasks_no,tasks_dt,tasks_man,tasks_content,tasks_hitrate,tasks_att1fname,tasks_att1url,tasks_att2fname,tasks_att2url from tasks where tasks_no='" + no + "'";
db database = new db();
database.RunSqlOutDs(ds, "task", taskSql);//主表
database.RunSqlOutDs(ds, "tasks", tasksSql);//从表
return ds;
}
DataSet取得了数据,但是跑出来的PDF文件却没有内容,真是奇怪!
不知道哪里出了问题,请指教?
------解决方案--------------------
没有写入成功被,检查下你写入PDF的代码!!!