zoukankan      html  css  js  c++  java
  • .net中生成excel后调整宽度

     生成excel后加上

       _Worksheet ActiveSheet;
            //_Chart ActiveChart;
            _Workbook oBook;
            _Application oExcel = new ApplicationClass();
            oExcel.Visible = false;
            oExcel.DisplayAlerts = false;
            oExcel.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityLow;
            oExcel.AlertBeforeOverwriting = false;
            oExcel.AskToUpdateLinks = false;

            oBook = oExcel.Workbooks.Open(Server.MapPath(xlsUrl), Type.Missing, Type.Missing, Type.Missing, Type.Missing
                , Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
                , Type.Missing, Type.Missing, Type.Missing);

            //这里会报一个错, 解决不了, 先这样应付一下吧.
            System.Threading.Thread.Sleep(500);
      ActiveSheet = (_Worksheet)oBook.ActiveSheet;
      ActiveSheet.ListObjects.AddEx(XlListObjectSourceType.xlSrcRange, ActiveSheet.UsedRange, Type.Missing, XlYesNoGuess.xlYes
                , Type.Missing, "TableStyleMedium2");
      oBook.Save();
      oBook.Close(Type.Missing, Type.Missing, Type.Missing);
      //wb.Close(pnull, pnull, pnull);
            oExcel.Quit();
            //Marshal.ReleaseComObject(ActiveSheet);
            //Marshal.ReleaseComObject(oBook);
            //Marshal.ReleaseComObject(oExcel);

  • 相关阅读:
    Istio安装配置及使用
    Istio介绍
    Rancher管理k8s集群
    EFK部署
    常见日志收集方案及相关组件
    Prometheus Pushgateway
    Prometheus监控拓展
    Prometheus PromQL语法
    开始新工作了
    SpringBlade 新系统 运行
  • 原文地址:https://www.cnblogs.com/y0umer/p/3839521.html
Copyright © 2011-2022 走看看