• 打印-Excel


           ///变量定义
    private System.Windows.Forms.Button printButton; private System.Drawing.Font printFont; private StreamReader streamToPrint; ///打印 private void pritf() { Microsoft.Office.Interop.Excel.ApplicationClass xlApp = new ApplicationClass(); Microsoft.Office.Interop.Excel.Workbooks xlWorkbooks; Microsoft.Office.Interop.Excel.Workbook xlWorkbook; Microsoft.Office.Interop.Excel.Worksheet xlWorksheet; System.Type tyWorkbooks; System.Reflection.MethodInfo[] methods; object objFilePath; object oMissing = System.Reflection.Missing.Value; ///EXCEL 名称和路径 string strFilePath = string.Format(@ url + "ecxel名称.xls");
    ///检查文件是否存在或者操作权限
    if (!System.IO.File.Exists(strFilePath)) { throw new System.IO.FileNotFoundException(); return; } try { xlApp.Visible = true; xlWorkbooks = xlApp.Workbooks; tyWorkbooks = xlWorkbooks.GetType(); methods = tyWorkbooks.GetMethods(); objFilePath = strFilePath; object Nothing = System.Reflection.Missing.Value; xlWorkbook = xlApp.Workbooks.Open(strFilePath, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing); xlWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkbook.Worksheets[1]; xlWorksheet.PrintPreview(true); } catch (Exception ex) { throw ex; } finally { if (xlApp != null) { xlApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp); xlApp = null; } GC.Collect(); } }
  • 相关阅读:
    62 ip与int类型的转换
    60再谈指针
    59任由制转换
    58进制转换工具
    吉哥工作
    apple
    找第一个非0元素的位置
    若干个数据之和 不考虑溢出
    汇编程序w=x*y+z-200
    4位bcd数转换为2进制数
  • 原文地址:https://www.cnblogs.com/lhlong/p/4877265.html
Copyright © 2020-2023  润新知