您的位置:首页 > 其它

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

2009-08-18 10:46 337 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: