Excel 온라인 미리 보기

2981 단어 Excel
여러 가지 문제에 부딪히다
 
 
 
          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 = @"\mold\123.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();

                }

            }

        }  

    }

}


  

좋은 웹페이지 즐겨찾기