Documentviewer WPF中的奇怪迹象

时间:2011-05-25 06:52:12

标签: c# wpf excel xps documentviewer

我正在为我的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

0 个答案:

没有答案