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.
Unfortunately, activation email could not send to your email. Please try again.

I want the heading to be in the same line, not if the table is to large to move to the next line ,espeaciylly if there is one column which is much more smaller but it does not need that much space.How ?

Thread ID:

Created:

Updated:

Platform:

Replies:

127072 Oct 24,2016 09:54 AM Oct 26,2016 02:46 AM ASP.NET MVC 5
loading
Tags: DocIO
Testname
Asked On October 24, 2016 09:54 AM

I want the heading to be in the same line, not if the table is to large to move to the next line ,espeaciylly if there is one column which is much more smaller but it does not need that much space.How ?
Word, table

Testname
Replied On October 24, 2016 10:53 AM

Or mybe its is better the table should get its width by the biggest coumn not header , I tried "table.TableFormat.IsAutoResized" but I need something which will take the biggest coumns width

Ayswarya Krishna Kumar [Syncfusion]
Replied On October 25, 2016 09:25 AM

Hi Customer,

Thank you for contacting Syncfusion support.

On analyzing, we have prepared the sample to meet your requirement. In the sample we have achieved the mentioned scenario with the following steps.
 

(1) Adds the table to the document section.
(2) Sets the first row of the table as table header row.
(3) Append text to each column.
(4)
We have found the maximum column width by measuring the text width using Graphics.MeasureString() method for each cell text content.
(5)
Sets the maximum column width to each column of the table.

We have attached the sample for your reference. Try running the sample and let us know whether it helps you?

Sample Link:
http://www.syncfusion.com/downloads/support/forum/127072/ze/GenerateWord-1906430176.zip

If we misunderstood your requirement, kindly elaborate your requirement with clear description (like screenshot of your output or expected output document), thereby we will analyse further on your requirement and update you with appropriate solution at the earliest.

Regards,
Ayswarya


Testname
Replied On October 25, 2016 10:51 AM

thanks, I get   "A first chance exception of type 'System.NullReferenceException' occurred in SyncfusionWrapper.dll", somewhere in "     foreach (WTableRow row in table.Rows)
                {
                    foreach (WTableCell cell in row.Cells)
                    {

                        //cell.CellFormat.Paddings.All = 5;
                        float textWidth = MeasureString(cell.LastParagraph.ChildEntities.LastItem as WTextRange);
                        if (textWidth > maxColumnWidth)
                            maxColumnWidth = textWidth;
                    }
                }"


Can you help ?

Testname
Replied On October 25, 2016 10:58 AM

cell.LastParagraph.ChildEntities.LastItem
'((Syncfusion.DocIO.DLS.ICompositeEntity)(((Syncfusion.DocIO.DLS.WTextBody)(cell)).LastParagraph))' is null

Ayswarya Krishna Kumar [Syncfusion]
Replied On October 26, 2016 02:46 AM

Hi Customer,

Thank you for your update.

On analyzing on the reported “Null reference Exception”, we found that the exception occurred due to accessing inappropriate child entity (there might be the chance of occurrences some other paragraph items like WPicture, BookmarkStart, BookmarkEnd, etc) from the paragraph entity collection. We have modified the sample to access the child entity of the paragraph with iterations. Please find the below code snippet for more understanding.

Code Snippet:

 
//To iterate the paragraphs of the cell 
foreach (WParagraph paragraph in cell.Paragraphs) 
{ 
   //To iterate the child entities of the paragraph 
   foreach (Entity entity in paragraph.ChildEntities) 
   { 
       //To Access the text range 
       if (entity is WTextRange) 
       { 
           //To measure the string width 
           float textWidth = MeasureString(entity as WTextRange); 
           if (textWidth > maxColumnWidth) 
           maxColumnWidth = textWidth; 
       } 
   } 
} 

We have attached the modified sample for your reference. Please find the modified sample from the below link.

Sample Link:
http://www.syncfusion.com/downloads/support/forum/127072/ze/GenerateWord-508976443.zip

For more details about the document elements please find the below UG Documentation links.

1) Working with Word document:
https://help.syncfusion.com/file-formats/docio/working-with-word-document

2) Working with Sections:
https://help.syncfusion.com/file-formats/docio/working-with-sections

3) Working with Paragraphs:
https://help.syncfusion.com/file-formats/docio/working-with-paragraph

 
4) Working with Tables:
https://help.syncfusion.com/file-formats/docio/working-with-tables

Note: If you could still reproduce the issue at your end, please provide us the sample that reproduce the issue, along with the Word document you are using, if any? So that we could analyze further and could provide you more appropriate details at the earliest.

Regards,
Ayswarya


CONFIRMATION

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.

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.

;