日期:2014-05-17 浏览次数:20417 次
//网站 ---添加引用--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