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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I need something like "ImportArray" for a word table.

Thread ID:





124044 May 11,2016 07:54 AM UTC May 17,2016 05:36 AM UTC ASP.NET MVC 3
Tags: DocIO
Asked On May 11, 2016 07:54 AM UTC

If I have a List of string arrays, how can I fill a word table dynamically like this in excel:

   List<MyCustomClass> tempMyCustomClasse = _dokEigenschaften.MyCustomClasse;

            int columnCounter = 1;
            foreach (MyCustomClass item in tempMyCustomClasse)
                worksheet.ImportArray(item.Werte, 1, columnCounter, true);

I need something like "ImportArray" for a word table.

Sarathkumar V [Syncfusion]
Replied On May 12, 2016 09:32 AM UTC

Hi Customer,

Currently DocIO does not have any specific API similar to IWorksheet.ImportArray(), but DocIO can achieve your requirement in sample level . We have prepared a sample to import the string array collection into Word table similar to IWorksheet.ImportArray(). Please find the sample from the below link and let us know if it helps.

Sample Link:

If we misunderstood any of your requirement, then kindly elaborate the actual requirement with detailed description. Thereby we will analyze further on the mentioned case and will provided you appropriate solution.


Replied On May 13, 2016 05:46 AM UTC

Yes, thats great, I changed my code to :

 WordDocument doc = new WordDocument();

            IWSection section = doc.AddSection();

            int maxRowCount = GetMaxZeilenAnzahl(singleTable);
            int maxCellCount = singleTable.Count;

            IWTable table = section.AddTable();
            table.TableFormat.IsAutoResized = true;
            table.TableFormat.Borders.BorderType = BorderStyle.Single;

            table.ResetCells(maxRowCount, maxCellCount);

            int x = 0;

            //Merge the array content into the table
            foreach (Excelwert item in singleTable)
                for (int y = 0; y < item.Werte.Length; y++)

                    if (item.Summenspalte && y == item.Werte.Length - 1) //letzte Zeile
                        int xWidth = singleTable.Count;
                        //table.LastRow.RowFormat.Borders.Top.LineWidth = 2.5f; //todo:this does not work, please change so that I do not have to use "for" loop

                        for (int cellCounter = 0; cellCounter < xWidth; cellCounter++)
                            table[y, cellCounter].CellFormat.Borders.Top.LineWidth = 1.5f;

                        IWTextRange textRangeGesamtergebnis = table[y, x].AddParagraph().AppendText(item.Werte[y]);
                        textRangeGesamtergebnis.CharacterFormat.FontName = "Verdana";
                        textRangeGesamtergebnis.CharacterFormat.FontSize = 8;
                        textRangeGesamtergebnis.CharacterFormat.Bold = true;
                        textRangeGesamtergebnis.CharacterFormat.UnderlineStyle = UnderlineStyle.Single;

                        IWTextRange textRangeText = table[y, x - 1].AddParagraph().AppendText(item.Werte[y]);
                        textRangeText.Text = "Gesamtvolumen";
                        textRangeText.CharacterFormat.FontName = "Verdana";
                        textRangeText.CharacterFormat.FontSize = 8;

                        if (xWidth > 3) //todo: check that I never run into an exception, if the cell does not exist
                            table.ApplyHorizontalMerge(y, 0, xWidth - 3); //mergen von cell

                        IWTextRange textRange = table[y, x].AddParagraph().AppendText(item.Werte[y]);
                        textRange.CharacterFormat.FontName = "Verdana";
                        textRange.CharacterFormat.FontSize = 8;

                        if (y == 0) //1. Zeile
                            textRange.CharacterFormat.Bold = true;


            return doc;

Please take a look at my todo's and fix as well I need the table to fulfill the entire width it does not matter whether it is landscape or portrait, by the way how can I center a table ?

Vijay Ramachandran [Syncfusion]
Replied On May 16, 2016 11:55 AM UTC

Hi Customer,

Thank you for your update.

Kindly provide us current output Word document and your expected output with clear details. Thereby
we will analyse further and will provided you appropriate solution.

Vijay R


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon