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

Not working Autofit

I'm using Syncfusion Essential Studio 6.4.0.15.

In the attached sample, text of multiple lines is set to IRange.Text Property.

------
var sb = new System.Text.StringBuilder();
sb.Append( string.Format( "row{0}", i ) );
sb.AppendLine();
sb.Append( string.Format( "col{0}", j ) );
var text = sb.ToString();
sheet.Range[i, j].Text = text;
------

And, the data is exporting to a Excel file.
But in the result of Excel file, whole cell is single-line.
I'd like to export remaining line count of whole cell, and whole cells autofitted by row height.

How can I achieve that?

4 Replies

IS Ichiro Sugimoto May 10, 2010 06:10 AM UTC

Sorry, I sent above though not finished writing.
So I send it again.

-----------------------------------------------------

I'm using Syncfusion Essential Studio 6.4.0.15.

In the attached sample, text of multiple lines is set to IRange.Text Property.

------
var sb = new System.Text.StringBuilder();
sb.Append( string.Format( "row{0}", i ) );
sb.AppendLine();
sb.Append( string.Format( "col{0}", j ) );
var text = sb.ToString();
sheet.Range[i, j].Text = text;
------

And after that, autofit all rows and export to Excel file.

------
for ( int i = 0 ; i < RowCount ; i++ ) {
sheet.AutofitRow( i + 1 );
}
for ( int j = 0 ; j < ColCount ; j++ ) {
sheet.AutofitColumn( j + 1 );
}
------

But in the result of Excel file, whole cell is not autofitted by row.
I'd like to export remaining line count of whole cell, and whole cells autofitted by row height.

How can I achieve that?



ExportExcelSample_2fa16470.zip


LR Lokesh R Syncfusion Team May 10, 2010 01:43 PM UTC

Hi Ichiro,

Thank you very much for using Syncfusion products.

I have analyzed your sample posted in your sample. In XlsIO, we have property called "Wrap text" associated with the IRange which helps to fit the text within the cell. I have attached the modified sample with this post and also i have added the code snippet for your reference. Could you please try the sample from the attachment and let us know if this helps you.

[C#]Code Snippet:

sheet.Range[i, j].WrapText = true;

Please, let us know if you need any clarifications.

Thanks,
Lokesh.





ExportExcelSample_6f87c253.zip


IS Ichiro Sugimoto May 11, 2010 02:37 AM UTC

Hi Lokesh,

I didn't know WrapText property of IRange interface.
I tried your sample, and got the result what I desired.

Thanks,
Ichiro.


LR Lokesh R Syncfusion Team May 11, 2010 05:18 AM UTC

Hi Ichiro,

Thank you very much for the update.

Regards,
Lokesh.

Loader.
Live Chat Icon For mobile
Up arrow icon