报表ActiveXViewer导出Excel,有些数据字符被截断,丢失。

chenquan223 2013-10-22 10:47:32
相关代码如下,
protected void ExportReport(string fileFormat)
{
DataDynamics.ActiveReports.Document.Document objDocument = null;

string fileName = "";
string filePath = "";
string contentType = "";
string tempName = Request.QueryString["ProductID"].ToString() ;

if (Request["PrintType"].ToLower() == "all")
{
string orderID = Request.QueryString["objectID"];
SalesOrderInfo objOrder = (new SalesOrderFacade()).GetSalesOrderInfo(orderID);
tempName = objOrder.CustomerPOID;
}

//fileName = System.Guid.NewGuid().ToString() + ".xls";
if (fileFormat.ToLower() == "pdf")
{
objDocument = WebViewer1.Report.Document;
pdfExporter = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();
fileName = tempName + ".pdf";
contentType = ReportConst.ReportFileType_PDF;
filePath = SyncFlo.EPM.EPMSystem.Configuration.FileDownloadRootDir + "\\" + fileName;
//filePath = fileName;
pdfExporter.Export(objDocument, filePath);
}
else
{
objDocument = LoadDataToExport();
xlsExporter = new DataDynamics.ActiveReports.Export.Xls.XlsExport();
fileName = tempName + ".xls";
contentType = ReportConst.ReportFileType_Excel;
filePath = SyncFlo.EPM.EPMSystem.Configuration.FileDownloadRootDir + "\\" + fileName;
//filePath = fileName;
xlsExporter.AutoRowHeight = true;
xlsExporter.UseCellMerging = true;
xlsExporter.RemoveVerticalSpace = true;
xlsExporter.FileFormat = DataDynamics.ActiveReports.Export.Xls.FileFormat.Xls97Plus;
xlsExporter.Export(objDocument, filePath);
}

if (fileName != "")
{
string VirtualPath = fileName;
Page.Response.Clear();
Page.Response.AddHeader("Content-Type", contentType);
Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(VirtualPath));
Page.Response.WriteFile(filePath);
Page.Response.End();

if (System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
}
}
}
...全文
116 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenquan223 2013-10-22
  • 打赏
  • 举报
回复
导出pdf文件又没有出现这种问题,只有导出Excel才出现字符丢失。
chenquan223 2013-10-22
  • 打赏
  • 举报
回复
求关注。。。。。
chenquan223 2013-10-22
  • 打赏
  • 举报
回复
比如我报表里面某一列的数据为jack001A 23, 导出为Excel后数据就变成了01A 23,前面的字符被截断了。

62,039

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧