php网站文档转html在线浏览,Office文档WEB端在线浏览(转换成Html)

usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Web;//using Microsoft.Office.Core;//using Word = Microsoft.Office.Interop.Word;

usingAspose.Cells;usingAspose.Slides.Pptx;namespaceCqscSecurityApplication.Utils

{public classOffice2HtmlHelper

{///

///Word转成Html///

/// 要转换的文档的路径

/// 转换成html的保存路径

/// 转换成html的文件名字

public static void Word2Html(string path, string savePath, stringwordFileName)

{//Word.ApplicationClass word = new Word.ApplicationClass();//Type wordType = word.GetType();//Word.Documents docs = word.Documents;//Type docsType = docs.GetType();//Word.Document doc = (Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { (object)path, true, true });//Type docType = doc.GetType();//string strSaveFileName = savePath + wordFileName + ".html";//object saveFileName = (object)strSaveFileName;//docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML });//docType.InvokeMember("Close", System.Reflection.BindingFlags.InvokeMethod, null, doc, null);//wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);

Aspose.Words.Document doc = new Aspose.Words.Document(path);//通过path(文件原始源路径)获取文档内容

wordFileName = wordFileName + ".html";string savePathss = Path.Combine(savePath, wordFileName);//合并转换后html文件路径

doc.Save(savePathss,Aspose.Words.SaveFormat.Html);//转换为html格式

}///

///Excel转成Html///

/// 要转换的文档的路径

/// 转换成html的保存路径

/// 转换成html的文件名字

public static void Excel2Html(string path, string savePath, stringwordFileName)

{//string str = string.Empty;//Microsoft.Office.Interop.Excel.Application repExcel = new Microsoft.Office.Interop.Excel.Application();//Microsoft.Office.Interop.Excel.Workbook workbook = null;//Microsoft.Office.Interop.Excel.Worksheet worksheet = null;//workbook = repExcel.Application.Workbooks.Open(path, 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);//worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//object htmlFile = savePath + wordFileName + ".html";//object ofmt = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;//workbook.SaveAs(htmlFile, ofmt, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);//object osave = false;//workbook.Close(osave, Type.Missing, Type.Missing);//repExcel.Quit();

Workbook workbook=newWorkbook(path);

wordFileName= wordFileName + ".html";string savePathss =Path.Combine(savePath, wordFileName);

workbook.Save(savePathss, SaveFormat.Html);

}///

///ppt转成Html///

/// 要转换的文档的路径

/// 转换成html的保存路径

/// 转换成html的文件名字

public static void PPT2Html(string path, string savePath, stringwordFileName)

{//Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();//string strSourceFile = path;//string strDestinationFile = savePath + wordFileName + ".html";//Microsoft.Office.Interop.PowerPoint.Presentation prsPres = ppApp.Presentations.Open(strSourceFile, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);//prsPres.SaveAs(strDestinationFile, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTrue);//prsPres.Close();//ppApp.Quit();

PresentationEx pres=newPresentationEx(path);

wordFileName= wordFileName + ".html";string savePathss =Path.Combine(savePath, wordFileName);

pres.Save(savePathss, Aspose.Slides.Export.SaveFormat.Html);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值