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
close icon

Autofit to Window/Contents

With tables in a Word document, it is possible to get them to Autofit to Contents or Autofit to Window (menu appears if you right click on a table).

If not, what's the best way to set cell widths?

Thanks
Nathan

9 Replies

SK Sarath Kumar G Syncfusion Team June 13, 2007 11:30 PM UTC

Hi Nathan,

Thank you for interest in Syncfusion products.

Thanks for suggesting this valuable feature of "Autofit to Window/Contents" to enhance our product. We have logged it as a feature request and notified our development team. We will implement this feature in our forthcoming new version releases or service pack releases. We usually have a timeframe of at least three months between releases. The feature implementation would also greatly depend on the factors like product design, code compatibility and complexity. We will get back to you once the feature is implemented.

You can set the width of table cell using Width property. The following is the code snippet to do so;


[C#]

// setting table cells width.
table[0, 0].Width = PointsConverter.FromInch(1);
table[0, 2].Width = PointsConverter.FromCm(1.5f);



You can also make use of "TextWrap","IsAutoResized" for wrapping up of text and resizing the table cell.

You can browse to the following URL for the sample which explains the above mentioned properties.

C:\...\My Documents\Syncfusion\EssentialStudio\5.1.0.51\Windows\DocIO.Windows\Samples\2.0\Tables\FormattingTable\cs

Please let me know if you face any issues.

Regards,
Sarath


PS Pavel Stilip November 2, 2010 01:06 PM UTC

Hello,
is AutoFit function implemented in latest version of DocIO and if so, can you please post some example (or some workaround to do AutoFit Contents).
I can't find this functionality.

Thanks for reply
Pavel



PR Poornima R Syncfusion Team November 3, 2010 11:31 AM UTC



Hi Pavel,

Thank you for your update.

The feature of "Autofit to Window/Contents" is not yet implemented in Essential DocIO. Currently AutoFitToWindow property can be achieved by creating the table using ResetCell() method. We have prepared the sample for your understanding. Could you please find the sample from the below link. Try running the sample and let us know if this helps.


Sample:
F62349-690331767.zip

Please let us know if you have any questions.

Regards,
Poornima




PS Pavel Stilip November 3, 2010 03:57 PM UTC

Hello,
thank your for the example. Could you please write some example of using "TextWrap" and "IsAutoResized" cell properties. I don't understand them well.

Is any plan to involve AutoFit functionality to DocIO - first post about it is from year 2007.

Regards,
Pavel




PR Poornima R Syncfusion Team November 4, 2010 12:37 PM UTC

Hi Pavel,

Thank you for your update.

We have created the sample for your requirement. Could you please find the sample from the below link. Try running the sample and let us know if this helps.

Sample:
F623491370624817.zip

Regarding AutoFit functionality, we will consider this feature in any one of our future releases.

Please let us know if you have any questions.

Regards,
Poornima



MI mier May 30, 2011 10:27 AM UTC

Is AUTOFIT available now? I found out ResetCells does not auto size the width of columns

thanks



PR Poornima R Syncfusion Team May 31, 2011 09:24 AM UTC

Hi Meir,

Thank you for your update.

We have not yet implemented the “Auto Fit functionality”. We are sorry for the inconvenience caused. ResetCells() method will automatically reset equal width for each column in a table. It does not reset the cell width based on its content. This method has 2 overloading function as follows

1) ResetCells(int rowsNum, int columnNum): This method takes the parameter as number of rows and columns for the table and automatically reset the columns to have equal width by considering the page width(excluding margin) as the width of the table. By this case the entire table column can be fit into a single page which is an alternative for AutoFit Window functionality.

2) ResetCell(int rowsNum, int columnNum, RowFormat format, float cellWidth): This method is used to specify the number of rows and columns for the table along with the predefined cell width for the entire cell within the table.

Please let us know if you have any questions.

Regards,
Poornima




MI mier June 1, 2011 04:59 AM UTC

But if I use 2nd method of ResetCells. All the columns have to be equal width, lets say I have three columns and need to have 3 different widths for the three columns, then how can I achieve that?



PR Poornima R Syncfusion Team June 6, 2011 06:24 AM UTC

Hi Mier,


Thank you for your update.

For your requirement of “Setting different width for each column in a table”, you need to explicitly specify the width for each cell within the table. We have prepared the sample for illustrating the same. Please find the sample from the below link. Try running the sample and let us know if this helps you.

Sample:
Sample-2032451537.zip

Please let us know if you have any questions.

Regards,
Poornima





Loader.
Live Chat Icon For mobile
Up arrow icon