• 在线预览Excel


    遇到的问题各种多

      <system.web>
       
        <identity impersonate="true" userName="Administrator" password="qqqq"/>

     http://zzhi191.blog.163.com/blog/static/1350849520129122280406/

    http://bbs.csdn.net/topics/330173175

    http://tanyanbo2.blog.163.com/blog/static/97339159201092941136797/

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Excel02 = Microsoft.Office.Interop.Excel;
    using System.Reflection;
    using Microsoft.Office.Interop.Excel;
    using System.IO;
    using System.Diagnostics; 
    
    namespace MouldWEBKT.ItemManage
    {
        public partial class TestPreView : System.Web.UI.Page
        {
         //   public string fileName = @"mold123.xls";
            protected void Page_Load(object sender, EventArgs e)
            {
                GenerationExcelHTML(@"D:22.xls", @"D:22.html");
            }
            protected bool GenerationExcelHTML(string FilePath, string saveFilePath)
            {
                try
                {
                    Excel02.Application app = new Excel02.Application();
                    app.Visible = false;
                    Object o = Missing.Value;
    
                    ///打开文件   
                    /*下面是Microsoft Excel 9 Object Library的写法: */
                    _Workbook xls = app.Workbooks.Open(FilePath, o, o, o, o, o, o, o, o, o, o, o, o);
    
                    /*下面是Microsoft Excel 10 Object Library的写法: */
                    //  _Workbook xls = app.Workbooks.Open(FilePath, o, o, o, o, o, o, o, o, o, o, o, o, o, o);  
    
                    ///转换格式,另存为 HTML   
                    /*下面是Microsoft Excel 9 Object Library的写法: */
                     xls.SaveAs(saveFilePath, Excel.XlFileFormat.xlHtml, o, o, o, o, XlSaveAsAccessMode.xlExclusive, o, o, o, o); 
    
                    /*下面是Microsoft Excel 10 Object Library的写法: */
                  //  xls.SaveAs(saveFilePath, Excel.XlFileFormat.xlHtml, o, o, o, o, XlSaveAsAccessMode.xlExclusive, o, o, o, o, o);
    
                    ///退出 Excel   
                    app.Quit();
                    return true;
                }
                catch
                {
                    return false;
                }
                finally
                {
                    //最后关闭打开的excel 进程   
                    Process[] myProcesses = Process.GetProcessesByName("EXCEL");
                    foreach (Process myProcess in myProcesses)
                    {
                        myProcess.Kill();
                    }
                }
            }  
        }
    }
    

      

  • 相关阅读:
    ST (Sparse Table:稀疏表)算法
    P3379 【模板】最近公共祖先(LCA)
    AT1357 n^p mod m(洛谷)
    poj2018 Best Cow Fences
    P1024 一元三次方程求解
    poj2456
    poj1064
    P2047 [NOI2007]社交网络(洛谷)
    poj1734
    洛谷P2886 [USACO07NOV]牛继电器Cow Relays
  • 原文地址:https://www.cnblogs.com/bingguang/p/3737002.html
Copyright © 2020-2023  润新知