网站建议:179001057@qq.com

WinForm中 如何直接调用Excel的打印预览功能,但不显示Excel文件

技术2022-05-12  0

 

using Microsoft.Office.Interop.Excel; //引用

public void PrintPriviewExcelFile(string filePath)        {            Microsoft.Office.Interop.Excel.ApplicationClass xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();            xlApp.Visible = true;            object oMissing = System.Reflection.Missing.Value;            Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(filePath, 0, true, 5, oMissing, oMissing, true, 1, oMissing, false, false, oMissing, false, oMissing, oMissing);            Microsoft.Office.Interop.Excel.Worksheet xlWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkbook.Worksheets[1];            xlWorksheet.PrintPreview(null);            xlApp.Visible = false;            xlWorksheet = null;        }


最新回复(0)