///
///
///
/// 文件路径
/// 保存html格式的路径
public static void WordHtml(string filePath, string htmlPath)
{
Word.Application wordApp;
Word.Document wordDoc;
Object Nothing = Missing.Value;
Console.WriteLine("Input path:");
Object path = Console.ReadLine();
path = filePath;
wordApp = new Word.ApplicationClass();
wordDoc = wordApp.Documents.Add(ref path, ref Nothing, ref Nothing, ref Nothing);
object format = Word.WdSaveFormat.wdFormatFilteredHTML;
Object newPath = htmlPath;
wordDoc.SaveAs(ref newPath, ref format, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
}
///
///
///
/// 文件路径
/// 保存html格式的路径
public static void ExeclHtml(string filePath, string htmlPath)
{
try
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = false;
app.DisplayAlerts = false;
object o = Missing.Value;
Microsoft.Office.Interop.Excel.Workbook workbook = null;
workbook = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
object fileName = htmlPath;
object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
workbook.SaveAs(fileName, format, o, o, o, o, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, o, o, o, o);
app.Quit();
Process[] myProces = Process.GetProcessesByName("EXCEL");
foreach (Process proces in myProces)
{
proces.Kill();
}
}
catch (Exception ex)
{
System.Console.Write(ex.Message);
}
}