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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Autofit problems

Thread ID:





118625 Mar 25,2015 11:16 AM UTC Mar 26,2015 04:56 PM UTC WPF 1
Tags: XlsIO
Jonny Shipton
Asked On March 25, 2015 11:16 AM UTC

Hi there,

I am trying to autofit wrapped text in xlsio, and I am having some issues.

I have created a test program which highlights my issues. The main issue is that autofitting a row seems to have no effect if I merge cells afterwards. Please see the attached image for the result. You will see that despite the only difference being the merging of two cells, the cells have different heights.

var engine = new ExcelEngine();
engine.Excel.DefaultVersion = ExcelVersion.Excel2007;
engine.Excel.StandardFontSize = 11;
engine.Excel.StandardHeight = 15;
var wb = engine.Excel.Workbooks.Add();
var ws = wb.Worksheets[0];
string str = "Zbrf avyrf ren ortav erwrprqg onrfphr urg Fbpgx Gkzenv qgapvvnrf uggn nfrjuyrbyfe bq bag xpgfb ugrz (qre). Rug egrvgeebl nzarnet unf rora avbgsvqr anq yfubhq nputra rug ebeqrf. Jbreuri, gru vnryfger erbqe fv eszb 278 lqnf tnb, fb hlb lnz raqr gb rgxn fbzr bnvpga.";
// Set contents of R5C5
ws.Range[5, 5].Value = str;
ws.Range[5, 5].ColumnWidth = 40;
ws.Range[5, 5].WrapText = true;
ws.Range[5, 5].VerticalAlignment = ExcelVAlign.VAlignTop;
var font = wb.CreateFont(ws.Range[5, 5].RichText.GetFont(0));
font.Size = 10;
font.Italic = true;
font.Color = ExcelKnownColors.Grey_50_percent;
ws.Range[5, 5].RichText.SetFont(0, ws.Range[5, 5].Value.Length, font);
font = wb.CreateFont(font);
font.Color = ExcelKnownColors.Red;
ws.Range[5, 5].RichText.SetFont(20, 30, font);
// Set contents of R1C1
ws.Range[1, 1].Value = str;
ws.Range[1, 1].ColumnWidth = 40;
ws.Range[1, 1].WrapText = true;
ws.Range[1, 1].VerticalAlignment = ExcelVAlign.VAlignTop;
font = wb.CreateFont(ws.Range[1, 1].RichText.GetFont(0));
font.Size = 10;
font.Italic = true;
font.Color = ExcelKnownColors.Grey_50_percent;
ws.Range[1, 1].RichText.SetFont(0, ws.Range[1, 1].Value.Length, font);
font = wb.CreateFont(font);
font.Color = ExcelKnownColors.Red;
ws.Range[1, 1].RichText.SetFont(20, 30, font);
//Autofit rows
ws.Range[5, 1].EntireRow.AutofitRows();
ws.Range[1, 1].EntireRow.AutofitRows();

// Merge R5C5 with R5C6
ws.Range[5, 5, 5, 6].Merge();


I have also had some issues with columns not autofitting properly, and not the autofit not including filter buttons. I haven't produced any test code for this yet though.

Any help would be much appreciated :)

Attachment: Excel_autofit_merged_cells_bf35b56.zip

Dilli Babu Nandha Gopal [Syncfusion]
Replied On March 26, 2015 04:56 PM UTC

Hi Jonny,

We were able to reproduce the problem and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates


Please let me know if you have any questions.


Dilli babu.


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon