using Spire.Xls; using System; using Learun.Util; using Spire.Doc; using System.IO; namespace Learun.Application.OA.File.FilePreview { public class FilePreviewBLL:FilePreviewIBLL { /// /// 获取EXCEL数据 /// /// public void GetExcelData(string path) { try { // load Excel file Workbook workbook = new Workbook(); workbook.LoadFromFile(path); workbook.SaveToFile(path.Substring(0, path.LastIndexOf(".")) + ".pdf", Spire.Xls.FileFormat.PDF); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } } /// /// 获取Word数据 /// /// public void GetWordData(string path) { try { Document document = new Document(); document.LoadFromFile(path); document.SaveToFile(path.Substring(0, path.LastIndexOf(".")) + ".pdf", Spire.Doc.FileFormat.PDF); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } } /// /// 获取Word数据 /// /// public void GetPptData(string path) { try { Document document = new Document(); document.LoadFromFile(path); document.SaveToFile(path.Substring(0, path.LastIndexOf(".")) + ".pdf", Spire.Doc.FileFormat.PDF); } catch (Exception) { throw (new Exception("文件丢失")); } } } }