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

autofitrow, merged cells in row

Hi!

My question is related to:
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=26974

Basically I have a row with merged cells and have set wraptext = true. I would like to call autofitrow so that this row is sized according to the contents of the merged cells. I know neither excel nor xlsio support this, with good reason I suppose. My question is however, do you guys have a workaround anywhere? Am I going to have to get down and dirty with a graphics object to do this :(?

Thanks

GA


3 Replies

MW Melba Winshia Syncfusion Team January 16, 2007 11:46 AM UTC

Hi GA,

It is not possible to AutoFit a row that contains a cell merged with cells in other rows. But as a workaround you can adjust row height and column width by using the following code snippets.

[C#]
sheet.Range["C3:C4"].Merge();
sheet.Range["C3"].AutofitColumns();

//Set Row height.(workaroud to autofitrows)
sheet.Range["C3"].RowHeight=42;

Here is the sample for your reference:

Test_XLSIO.zip

Please take a look at the sample above and let me know if you have any other questions.

Best Regards,
Melba


AI Amal Ibrahim April 10, 2008 01:01 PM UTC

Hi,
Is there a better work around in XLSIO 6.2? I need to merge the cells then autofit the rows this seems not to work at all.
Please advice.
Thanks
Amal



YG Yavanaarasi G Syncfusion Team April 18, 2008 04:48 AM UTC

Hi Amal,

Sorry for the delay in responding.

I am not able to reproduce the issue that you mentioned here. As per your requirements I have created one sample, merge the cells and autofit the rows. Here it works fine. I have tested this issue in Win Xp with service pack2,.Netframework 3.5, Office 2003.

Please refer the below code snippet:

[C#]
sheet1.Range["A9:A11"].Merge();
sheet1.Range["B9:B14"].Text = "This is the Autofit Rows";
sheet1.Range["B9:B14"].AutofitRows();


Here is the sample for your reference:
http://websamples.syncfusion.com/samples/XlsIO.Windows/42897/main.htm

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?

Also please provide your system details and the office version.

Regards,
G.Yavana


Loader.
Live Chat Icon For mobile
Up arrow icon