Aspose office (Excel,Word,PPT),PDF 在线预览

web开发作者:dayu日期:11天前点击:6

就是做个备份,拿的是试用版的 Aspose

  1. /// <summary>
  2. /// Aspose office (Excel,Word,PPT),PDF 在线预览
  3. /// </summary>
  4. /// <param name="sourceDoc">需要预览的文件地址</param>
  5. /// <param name="saveDoc">展示的html文件地址</param>
  6. public void Goto(string sourceDoc, string saveDoc)
  7. {
  8. string s_sourceDoc = Server.MapPath(sourceDoc);

  9. string s_saveDoc = Server.MapPath(saveDoc);

  10. string docExtendName = Path.GetExtension(s_sourceDoc).ToLower();

  11. switch (docExtendName)
  12. {
  13. case ".doc":
  14. case ".docx":
  15. Aspose.Words.Document doc = new Aspose.Words.Document(s_sourceDoc);
  16. doc.Save(s_saveDoc, Aspose.Words.SaveFormat.Html);
  17. Response.Redirect(saveDoc);
  18. break;
  19. case ".xls":
  20. case ".xlsx":
  21. Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(s_sourceDoc);
  22. workbook.Save(s_saveDoc, Aspose.Cells.SaveFormat.Html);
  23. Response.Redirect(saveDoc);
  24. break;
  25. case ".ppt":
  26. case ".pptx":
  27. Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(s_sourceDoc);
  28. pres.Save(s_saveDoc, Aspose.Slides.Export.SaveFormat.Html);
  29. Response.Redirect(saveDoc);
  30. break;
  31. case ".pdf":
  32. Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(s_sourceDoc);
  33. pdf.Save(s_saveDoc, Aspose.Pdf.SaveFormat.Html);
  34. Response.Redirect(saveDoc);
  35. break;
  36. }
  37. }

http://download.csdn.net/detail/hou3125378/9909973

Aspose office (Excel,Word,PPT),PDF 在线预览

原文地址:http://www.cnblogs.com/houlin/p/7233954.html


下一篇       上一篇