Aref Zamani
Aref Zamani

Reputation: 2062

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

I have a excel file and i want to import a sheet from it to my .DOCX file created by aspose.word .I tried InsertOleObject but that did not show any table and just show a object shape that linked to excel file.

Upvotes: 0

Views: 1372

Answers (1)

Tilal Ahmad
Tilal Ahmad

Reputation: 939

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.

Upvotes: 2

Related Questions