近期看了一篇文章代码如下,由于我用的是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");
}
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 o,ref o);
xls.SaveAs(fileName, format, o, o, o, o, XlSaveAsAccessMode.xlExclusive, o, o, o, o);