日期:2014-05-17  浏览次数:20378 次

ASP.NET把word和Excel转换成HTML浏览的问题
近期看了一篇文章代码如下,由于我用的是VS2011的版本所以我添加引用的时候是
com--Microsoft Excel 12.0 object Library    .// Microsoft Word 12.0 object Library   
当把下面代码copy到VS中 using Excel会报错误,程序联想不到 Using Excel;求解答该如何引用啊            

//网站 ---添加引用--com--Microsoft Excel 9.0 object Library    .// Microsoft Word 9.0 object Library               

using System.Reflection;
using Excel;
using System.Diagnostics;
using Microsoft.Office;

public partial class tel : System.Web.UI.Page
{
      protected void Page_Load(object sender, EventArgs e)
      {  
          //word
          Response.Write(Get_Html("New.doc"));
         //excel
          ExcelConvertToHtml("E:\\12345.xls","E:\\aaa.html");
      }

      protected void ExcelConvertToHtml(string xlsPath, string htmlPath)
      {
          try
          {
              Excel.Application app = new Excel.Application();
              app.Visible = false;
              Object o = Missing.Value;

              /// _Workbook     xls=app.Workbooks.Open(xlsPath,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o);   

               _Workbook xls = app.Workbooks.Open(xlsPath, o, o, o, o, o, o, o, o, o, o, o, o);
              object fileName = htmlPath;
              object format = Excel.XlFileFormat.xlHtml;//Html   

              // xls.SaveAs(ref     fileName,ref     format,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref     o,ref    &n