件
Type documentType = document.GetType();
documentType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, document, new object[] { htmlFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });
// 退出
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
}
// 添加COM引用:Microsoft Excel X.0 Object Library
public void ConvertXlsToHtml(string xlsFileName, string htmlFileName)
{
// 初始化
Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
Type excelType = excel.GetType();
Microsoft.Office.Interop.Excel.Workbooks workbooks = excel.Workbooks;
// 打开文件
Type workbooksType = workbooks.GetType();
Microsoft.Office.Interop.Excel.Workbook workbook = (Microsoft.Office.Interop.Excel.Workbook)workbooksType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, workbooks, new Object[] { xlsFileName, true, true });
// 另存文件
Type workbookType = workbook.GetType();
workbookType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, workbook, new object[] { htmlFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml });
// 退出
excelType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, excel, null);
}
================================================================================================================