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

[C#]将excel文件转换为html文件

原文:

http://ittalk.blog.hexun.com/8373647_d.html

using Excel;
using System.Reflection;?

?public void ReadExcel(string rFilePath,string rHtmlFilePath)
??{
???Excel.Application?? repExcel?? =?? new Excel.Application();???
???Excel.Workbook?? workbook?? =?? null;???
????
???//xlsFile为Excel文件路径???
???workbook?? =?? repExcel.Application.Workbooks.Open(rFilePath,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value);?????
????
???//htmlFile?? 是要另存的html文件名??

???object?? ofmt?? =?? Excel.XlFileFormat.xlHtml;???
???workbook.SaveAs(rHtmlFilePath,???
????ofmt,???
????Missing.Value,???
????Missing.Value,???
????Missing.Value,???
????Missing.Value,
????Excel.XlSaveAsAccessMode.xlNoChange,???
????Missing.Value,???
????Missing.Value,
????Missing.Value,
????Missing.Value,
????Missing.Value);???
????
???object?? osave?? =?? false;???
???workbook.Close(osave,Missing.Value,Missing.Value);??

??}