简体   繁体   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文件的对象形状。

Unfortunately, there is no direct way to convert Excel document to Word. 不幸的是,没有直接的方法可以将Excel文档转换为Word。 However, it is possible with the collaboration of Aspose.Cells and Aspose.Pdf. 但是,可以通过Aspose.Cells和Aspose.Pdf的协作来实现。 First convert Excel document to PDF using Aspose.Cells and later convert the PDF document to Word document using Aspose.Pdf. 首先使用Aspose.Cells将Excel文档转换为PDF,然后使用Aspose.Pdf将PDF文档转换为Word文档。 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. 我与Aspose合作担任开发人员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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