沒有什么營養,就是調用一下這個組件。其實一開始用的是Microsoft.Office.Interop.Excel;Microsoft.Office.Interop.Word
但是在服務器要注意,服務器要安裝Office的指定版本,具體是哪個版本要看你引用的版本。
而且在服務器調用+com組件,對權限有很多要求。網上有很多答案了,這里主要說aspose
using Aspose.Cells;//Excel
using Aspose.Slides;//PPT
public static void ppt2Pdf(string filePath,string savePath){
Presentation ppt = new Presentation(filePath);
ppt.Save(savePath, Aspose.Slides.Export.SaveFormat.Pdf);
}
public static void excel2Pdf(string filePath, string savePath)
{
Workbook excel = new Workbook(filePath);
excel.Save(savePath, Aspose.Cells.SaveFormat.Pdf);
}
using Aspose.Words;
Document doc = new Document(serverPath);
doc.Save(savePath);
DLL的網盤:鏈接: http://pan.baidu.com/s/1bBeizs 密碼: wfzh
自己引用轉換就可以了
不過不管微軟的組件還是Aspose都有缺點。馬上給大家分享NPOI
使用 NPOI 你就可以在沒有安裝 Office 或者相應環境的機器上對 WORD/EXCEL 文檔進行讀寫