zoukankan      html  css  js  c++  java
  • 打印-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(); } }
  • 相关阅读:
    编译i386 Linux 内核并基于 QEMU 运行
    在 Linux 上编译运行并测试 LwIP 协议栈性能
    gdb 重定位源文件目录
    SkyWalking 分布式追踪系统
    微服务化的基石——持续集成(二)
    微服务容器化的分工与合作,促进DevOps (一)
    预订餐位
    单词记录1.26
    What do you do on weekends
    make a travel plan(LC)
  • 原文地址:https://www.cnblogs.com/lhlong/p/4877265.html
Copyright © 2011-2022 走看看