原創|使用教程|編輯:郝浩|2013-09-25 14:22:02.000|閱讀 641 次
概述:文檔操作組件DevExpress Document Server能夠實現對電子表格文件的加載保存與導出,慧都就來為大家詳細介紹具體方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
文檔操作組件DevExpress Document Server能夠實現對電子表格文件(如Excel等)的加載保存與導出,慧都就來為大家詳細介紹具體方法。
DevExpress Document Server支持將現存電子表格文檔通過Workbook.LoadDocument方法加載到Workbook對象中。
示例代碼如下:
using System.IO; using DevExpress.Spreadsheet; // ... Workbook workbook = new Workbook(); // Load a workbook from the stream. using (FileStream stream = new FileStream("Documents\\Document.xlsx", FileMode.Open)) { workbook.LoadDocument(stream, DocumentFormat.OpenXml); }
要將加載到Workbook對象的內容保存到文檔中,需要使用Workbook.SaveDocument方法。
示例代碼如下:
using System.IO; using DevExpress.Spreadsheet; // ... Workbook workbook = new Workbook(); // ... // Save the modified document to the stream. using (FileStream stream = new FileStream("Documents\\SavedDocument.xlsx", FileMode.Create, FileAccess.ReadWrite)) { workbook.SaveDocument(stream, DocumentFormat.OpenXml); }
使用Workbook.ExportToPdf就能將workbook導出為PDF格式,示例代碼如下:
using (FileStream pdfFileStream = new FileStream("Documents\\Document_PDF.pdf", FileMode.Create)) { workbook.ExportToPdf(pdfFileStream); }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網