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

Column widths - Auto width

Hi

I am using XlsIO to merge together .xls files that have been created in one of more unusual flavours of Excel (See Attached). This is an unsupported format for XlsIO.

My approach was to manually parse the .xls file myself and use a Syncfusion.XlsIO.IWorkbook to build up the merged 'output' document.

This has been reasonably successfull and I have managed to port all of the information and style information except for the column widths. In my 'output' documents, the column widths are different than in the input document.

There is nothing in the source file that explicitly specifies column width however I can see this style element in the input document for 'col'...

col
{mso-width-source:auto;}

It appears to indicate that the column should automatically determine its width based on content and I suspect it is the equivalent of this property I need to set in order for my output document to match the look of the input document.

How would I go about setting an equivalent property in my XlsIO Syncfusion.XlsIO.IWorkbook instance ??

Michael





Sample_public_e7b36704.XLS

1 Reply

GM Geetha M Syncfusion Team June 29, 2009 08:40 AM UTC

Hi Michael,

Thank you for your interest in Syncfusion products.

You can set the column width to be calculated as per the content as mentioned in the code snippet given below.

sheet.UsedRange.AutofitColumns();

or you can manually set the width as below

sheet.SetColumnWidth(1, 8.43);

where '1' refers to the first column in the sheet.

Please try this and let me know if you have any questions.

Regards,
Geetha

Loader.
Live Chat Icon For mobile
Up arrow icon