Asp.net MVC 利用(aspose+pdfobject.js) 实现在线预览word、excel、ppt、pdf文件
来源:互联网 发布:win8.1配置java环境 编辑:程序博客网 时间:2024/05/29 04:34
在线预览word、excel、ppt利用aspose动态生成html
主要代码
private bool OfficeDocumentToHtml(string sourceDoc, string saveDoc){ bool result = false; //获取文件扩展名 string docExtendName = System.IO.Path.GetExtension(sourceDoc).ToLower(); switch (docExtendName) { case ".doc": case ".docx": Aspose.Words.Document doc = new Aspose.Words.Document(sourceDoc); doc.Save(saveDoc, Aspose.Words.SaveFormat.Html); result = true; break; case ".xls": case ".xlsx": Workbook workbook = new Workbook(sourceDoc); workbook.Save(saveDoc, SaveFormat.Html); result = true; break; case ".ppt": case ".pptx": //templateFile = templateFile.Replace("/", "\\"); //string templateFile = sourceDoc; //templateFile = templateFile.Replace("/", "\\"); PresentationEx pres = new PresentationEx(sourceDoc); pres.Save(saveDoc, Aspose.Slides.Export.SaveFormat.Html); result = true; break; default: break; } return result;}
在线预览pdf利用pdfobject.js生成(aspose也可以做到,但效果不理想)
主要代码
private bool PdfToHtml(string fileName, string tempFile, string saveDoc){ //---------------------读html模板页面到stringbuilder对象里---- StringBuilder htmltext = new StringBuilder(); using (StreamReader sr = new StreamReader(tempFile)) //模板页路径 { String line; while ((line = sr.ReadLine()) != null) { htmltext.Append(line); } sr.Close(); } fileName = fileName.Replace("\\", "/"); //----------替换htm里的标记为你想加的内容 htmltext.Replace("$PDFFILEPATH", fileName); //----------生成htm文件------------------―― using (StreamWriter sw = new StreamWriter(saveDoc, false, System.Text.Encoding.GetEncoding("utf-8"))) //保存地址 { sw.WriteLine(htmltext); sw.Flush(); sw.Close(); } return true;}效果图
预览Word
预览excel
预览ppt
预览pdf
源码下载
http://download.csdn.net/detail/jx_521/9693817
0 0
- Asp.net MVC 利用(aspose+pdfobject.js) 实现在线预览word、excel、ppt、pdf文件
- asp.net实现word、excel、ppt、pdf在线预览
- ASP.NET MVC在线预览Excel、Word、TXT、PDF文件
- 【顶级推荐】NET-Word、Excel、PPT、PDF在线预览解决方案
- PDF.js+pdfobject.js实现文档的在线预览
- .net 实现Office文件预览,word文件在线预览、excel文件在线预览、ppt文件在线预览,excel转html,office格式转换,
- .net 实现word、excel、ppt、pdf预览功能
- Asp.Net Word、Excel转PDF在线预览
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!(续)
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!(续)
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你
- [Asp.net]常见word,excel,ppt,pdf在线预览方案,有图有真相,总有一款适合你!
- .net 实现Office文件预览 Word PPT Excel
- 直接在线预览Word、Excel、TXT文件之ASP.NET
- Android实现在线预览office文档(Word,Pdf,excel,PPT.txt等格式)
- Word Excel PPT在线预览
- 为RecyclerView打造通用Adapter 让RecyclerView更加好用
- 第十二周 求两数的最大公约数
- 盗版毕加索
- app接口设计之signature签名的php实现
- 十一章 上机1
- Asp.net MVC 利用(aspose+pdfobject.js) 实现在线预览word、excel、ppt、pdf文件
- samba 安装记录
- LitePal总结
- 十二章 未完
- as2.2 反射碰到的一个问题
- HashMap 详解
- 用户输入不期望的输入
- 十一章 上机2
- Ecshop后台拿shell方法总结