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(); } }
  • 相关阅读:
    区块链技术的自我见解
    Nengo 神经网络
    elasticsearch更新操作问题
    elasticsearch httpclient认证机制
    spring 常见的注解
    elasticsearch插入索引文档 对数字字符串的处理
    Elasticsearch搜索含有数字标签的处理
    Elasticsearch 插入地理索引文档一直为空
    UVA-10163 Storage Keepers (0-1背包)
    UVA-1632 Alibaba (区间DP+滚动数组)
  • 原文地址:https://www.cnblogs.com/lhlong/p/4877265.html
Copyright © 2011-2022 走看看