简体   繁体   中英

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

我有一个excel文件,我想从中将工作表导入到由aspose.word创建的.DOCX文件中。我尝试了InsertOleObject ,但未显示任何表格,只显示了链接到excel文件的对象形状。

Unfortunately, there is no direct way to convert Excel document to Word. However, it is possible with the collaboration of Aspose.Cells and Aspose.Pdf. First convert Excel document to PDF using Aspose.Cells and later convert the PDF document to Word document using Aspose.Pdf. Please check following sample code for the purpose.

//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);

I work with Aspose as developer evangelist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM