就是做个备份,拿的是试用版的 Aspose
- /// <summary>
- /// Aspose office (Excel,Word,PPT),PDF 在线预览
- /// </summary>
- /// <param name="sourceDoc">需要预览的文件地址</param>
- /// <param name="saveDoc">展示的html文件地址</param>
- public void Goto(string sourceDoc, string saveDoc)
- {
- string s_sourceDoc = Server.MapPath(sourceDoc);
- string s_saveDoc = Server.MapPath(saveDoc);
- string docExtendName = Path.GetExtension(s_sourceDoc).ToLower();
- switch (docExtendName)
- {
- case ".doc":
- case ".docx":
- Aspose.Words.Document doc = new Aspose.Words.Document(s_sourceDoc);
- doc.Save(s_saveDoc, Aspose.Words.SaveFormat.Html);
- Response.Redirect(saveDoc);
- break;
- case ".xls":
- case ".xlsx":
- Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(s_sourceDoc);
- workbook.Save(s_saveDoc, Aspose.Cells.SaveFormat.Html);
- Response.Redirect(saveDoc);
- break;
- case ".ppt":
- case ".pptx":
- Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(s_sourceDoc);
- pres.Save(s_saveDoc, Aspose.Slides.Export.SaveFormat.Html);
- Response.Redirect(saveDoc);
- break;
- case ".pdf":
- Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(s_sourceDoc);
- pdf.Save(s_saveDoc, Aspose.Pdf.SaveFormat.Html);
- Response.Redirect(saveDoc);
- break;
- }
- }
http://download.csdn.net/detail/hou3125378/9909973
时间: 2024-10-24 10:38:27