簡體   English   中英

通過aspose.word導入Word中的Excel表格以獲取C#.Net

[英]Import excel table sheet in word by aspose.word for C# .Net

我有一個excel文件,我想從中將工作表導入到由aspose.word創建的.DOCX文件中。我嘗試了InsertOleObject ,但未顯示任何表格,只顯示了鏈接到excel文件的對象形狀。

不幸的是,沒有直接的方法可以將Excel文檔轉換為Word。 但是,可以通過Aspose.Cells和Aspose.Pdf的協作來實現。 首先使用Aspose.Cells將Excel文檔轉換為PDF,然后使用Aspose.Pdf將PDF文檔轉換為Word文檔。 為此,請檢查以下示例代碼。

//Use Aspose.Cells to convert XLS to Word document
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook("Book1.xls");
// To convert first sheet only you need to hide other worksheets
workbook.Worksheets[1].IsVisible = false;
// Save the XLS document into PDF document
workbook.Save("output.pdf", Aspose.Cells.SaveFormat.Pdf);
//Use Aspose.Pdf to convert PDF to Word document
// Open the source PDF document
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("output.pdf");
// Save the PDF file into Word document
pdfDocument.Save("PDFToDOCX_out.docx", Aspose.Pdf.SaveFormat.DocX);

我與Aspose合作擔任開發人員。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM