首页 新闻 会员 周边

C# Execl WOrd 转化为html显示在页面上

0
悬赏园豆:40 [已关闭问题] 关闭于 2015-08-07 16:31

如何将execl  word 转化成流 然后保存到页面显示出来啊、!!!!

有一个文件,文件后面有两个按钮,一个是显示一个是下载,点击显示的时候直接显示为html格式文本。

行走的小蜗牛的主页 行走的小蜗牛 | 初学一级 | 园豆:5
提问于:2015-08-03 16:15
< >
分享
所有回答(4)
0

看了你的回复,瞬间觉得,你要的仅仅的代码~

幻天芒 | 园豆:37175 (高人七级) | 2015-08-04 08:54
0

建议搜下 Aspose.Word 非常好用,能直接把word转换成html。

冲动 | 园豆:394 (菜鸟二级) | 2015-08-04 14:01
0

一般是office转pdf,再转swf 就可以在线预览

阿炬 | 园豆:268 (菜鸟二级) | 2015-08-07 16:28
0

/// <summary>
///
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="htmlPath">保存html格式的路径</param>
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);
}

 

/// <summary>
///
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="htmlPath">保存html格式的路径</param>
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);
}
}

行走的小蜗牛 | 园豆:5 (初学一级) | 2015-08-07 16:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册