遇到的问题各种多
<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(); } } } } }