Documentviewer WPF 中的奇怪迹象
我正在向我的 WPF 项目添加一个文档查看器,一切看起来都很完美。但是,当我尝试打开另一个 xps 文件时,文档查看器会在我的文档中放置一些 [?] 符号。
这是我的代码:
if (xps != null)
{
xps.Close();
xps = null;
}
docViewer.Document = null;
Microsoft.Office.Interop.Excel.Application eApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook eWb;
Microsoft.Office.Interop.Excel.Worksheet eWs;
eApp.Visible = false;
eWb = eApp.Workbooks.Open(gekozenProductBestand, false,false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eWs = (Microsoft.Office.Interop.Excel.Worksheet)eWb.Worksheets[1];
eWs.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
eWb.ExportAsFixedFormat(XlFixedFormatType.xlTypeXPS, System.IO.Path.GetTempPath() + "producten", XlFixedFormatQuality.xlQualityStandard, true, true, Type.Missing, Type.Missing, false, Type.Missing);
eApp.DisplayAlerts = false;
eApp.Quit();
xps = new XpsDocument(System.IO.Path.GetTempPath() + "producten.xps", System.IO.FileAccess.Read);
docViewer.Document = xps.GetFixedDocumentSequence();
docViewer.FitToWidth();
eApp.DisplayAlerts = false;
eWs = null;
eWb = null;
eApp.Quit();
eApp = null;
GC.Collect();
最后一张图片让我清楚: http://img818.imageshack.us/img818/7043/knipselq.png
I'm adding a document viewer to my WPF project and all seems perfect. But when I try to open another xps file, the documentviewer places some [?] signs in my document.
Here's my code :
if (xps != null)
{
xps.Close();
xps = null;
}
docViewer.Document = null;
Microsoft.Office.Interop.Excel.Application eApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook eWb;
Microsoft.Office.Interop.Excel.Worksheet eWs;
eApp.Visible = false;
eWb = eApp.Workbooks.Open(gekozenProductBestand, false,false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, false, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
eWs = (Microsoft.Office.Interop.Excel.Worksheet)eWb.Worksheets[1];
eWs.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
eWb.ExportAsFixedFormat(XlFixedFormatType.xlTypeXPS, System.IO.Path.GetTempPath() + "producten", XlFixedFormatQuality.xlQualityStandard, true, true, Type.Missing, Type.Missing, false, Type.Missing);
eApp.DisplayAlerts = false;
eApp.Quit();
xps = new XpsDocument(System.IO.Path.GetTempPath() + "producten.xps", System.IO.FileAccess.Read);
docViewer.Document = xps.GetFixedDocumentSequence();
docViewer.FitToWidth();
eApp.DisplayAlerts = false;
eWs = null;
eWb = null;
eApp.Quit();
eApp = null;
GC.Collect();
And finally an image to make myself clear :
http://img818.imageshack.us/img818/7043/knipselq.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论