ar11导出word文档,docx格式错乱
导出代码如下:public void ProcessRequest(HttpContext context)
{
String filePath = context.Request.FilePath;
filePath = filePath.Remove(filePath.Length - 4);
String reportPath = context.Server.MapPath(filePath);
String str =context.Request.QueryString["param"];
PageReport rpt = new PageReport(new FileInfo(reportPath));
String mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
String filename = "test.docx";
context.Response.ContentType = mimeType;
context.Response.Clear();
context.Response.AddHeader("content-disposition", "attachment;filename=" + filename);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
GrapeCity.ActiveReports.Export.Word.Page.Settings wordSetting = new GrapeCity.ActiveReports.Export.Word.Page.Settings();
wordSetting.UseMhtOutput = true;
//docx
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.OOXML;
//doc
//wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.HTML;
GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension wordRenderingExtension =
new GrapeCity.ActiveReports.Export.Word.Page.WordRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
rpt.Report.ReportParameters.DefaultValue.Values.Add("EUNBDD180300029");
rpt.Document.Render(wordRenderingExtension, outputProvider, wordSetting);
outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
context.Response.BinaryWrite(ms.ToArray());
context.Response.End();
}
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.OOXML; 这句是导出docx格式的,导出后office2007无法打开,office2010打开格式错乱。
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.HTML; 设置成doc格式后打开是正常的。
附件是doc和docx的文件。
本帖最后由 KearneyKang 于 2018-3-13 10:53 编辑
wordSetting.FileFormat = GrapeCity.ActiveReports.Export.Word.Page.FileFormat.HTML;这种格式显示正常,不能满足你们的需求嘛
这种是office2003的格式,导出的格式和通过ar的控件进行预览再进行导出的格式有部分差异。有些格式和字体在office2003中肯定是没有的。所以需要能导出office的docx版本的文件。并且通过预览导出的docx是正常,应该是代码里哪一步没有调用的问题。 好的,这个问题我需要做一个验证。可能需要一点时间 好的,这个问题我需要做一个验证。可能需要一点时间
页:
[1]