We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Import excel table into word

I looking a sample how to do this “Combine with Essential DocIO to generate Word documents from Excel worksheets. You can easily create tables in a Word document by exporting a range of cell values, including their formatting, from the Excel worksheet into that Word document. Again, no need for Excel or Word to be installed.”

I can't find some internal converter like for pdf and the way to simple insert datatable. How can i do it? Should i do it cell by cell?


8 Replies

SR Sridhar Syncfusion Team October 30, 2013 11:38 AM UTC

Hi Nina Zarina,

Thank you for using Syncfusion products.

We have prepared the sample for importing excel table data to word document and attached here for your reference. Please try the sample at your side and let us know if this helps you.

Please let us know if you need any further assistance.

Thanks,

Sridhar.S



ExceltoWord_3155de16.zip


NZ Nina Zarina November 1, 2013 02:14 PM UTC

Thank you, Shridar.

It was a very useful sample, but I have additional questions, first of all: how to convert merge cells?I try it with my excel file, result in attachment.



Test_5c39edd0.zip


NZ Nina Zarina November 6, 2013 07:31 AM UTC

Sridhar, I found the how way to convert merge cells.

But I still need help to convert rich text, maybe you have some sample of it?



SR Sridhar Syncfusion Team November 11, 2013 12:30 PM UTC

Hi Nina Zarina,

Thank you so much for the update.

Currently, we do not have support for converting the RTF text from excel table to work table. We are sorry for the inconvenience.

Thanks,

Sridhar.S



CY cyril April 22, 2014 12:22 PM UTC

hi

why can't i download any example from the topic?


SB Sathish Babu R Syncfusion Team May 21, 2014 01:30 PM UTC

Hi Cyril,

Sorry for the inconvenience, earlier links are broken. You can find the sample in the below link.

Sample to Export Excel to Word

Please let us know if you need any clarification.

Thanks,
Sathish


JS Julio Szabo February 25, 2021 01:49 AM UTC

Hello I can not download the samples of this thread.
I'm trying to export a workbook to docx but I have MemoryStreams not physicals files.
Can someone help me please?

Thanks!
Julio


SK Shamini Kiruba Sobers Syncfusion Team February 25, 2021 03:09 PM UTC

Hi Julio, 

Sorry for the inconvenience. The links shared years ago are now broken. And, we don’t have direct support for Excel to Word conversion. The sample is an workaround with the below code which converts the Excel workbook to image and then the image is added into the Word document. 

Code snippet: 

using (ExcelEngine excelEngine = new ExcelEngine()) 
{ 
    IApplication application = excelEngine.Excel; 
 
    application.DefaultVersion = ExcelVersion.Excel2016; 
 
   //Open the Excel workbook 
    FileStream fileStream = new FileStream(Server.MapPath("App_Data/Sample.xlsx"), FileMode.Open, FileAccess.ReadWrite); 
    IWorkbook workbook = application.Workbooks.Open(fileStream); 
    IWorksheet worksheet = workbook.Worksheets[0]; 
 
    // Convert as bitmap 
    System.Drawing.Image image = worksheet.ConvertToImage(1, 1, 41, 4); 
    image.Save(Server.MapPath("App_Data/Sample.png"), ImageFormat.Png); 
 
    //Create a new Word document 
    WordDocument document = new WordDocument(); 
    //Adds section to the document 
    IWSection section = document.AddSection(); 
    //Adds new paragraph to the section 
    IWParagraph firstParagraph = section.AddParagraph(); 
                 
    MemoryStream stream = new MemoryStream(); 
    image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); 
    byte[] imageBytes = stream.ToArray(); 
    //Append the picture to the document 
    IWPicture picture = firstParagraph.AppendPicture(imageBytes); 
    //Save the document as .docx and download 
    document.Save("Output.docx", FormatType.Docx, Response, HttpContentDisposition.Attachment); 
} 


Kindly let us know if the sample helps. 

Regards, 
Shamini 


Loader.
Up arrow icon