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.
Unfortunately, activation email could not send to your email. Please try again.

Autofit problems

Thread ID:

Created:

Updated:

Platform:

Replies:

118625 Mar 25,2015 07:16 AM Mar 26,2015 12:56 PM WPF 1
loading
Tags: XlsIO
Jonny Shipton
Asked On March 25, 2015 07:16 AM

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();

wb.SaveAs("D:\\test_x.xlsx");
engine.Excel.Workbooks.Close();

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 :)
Thanks,
Jonny


Attachment: Excel_autofit_merged_cells_bf35b56.zip

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

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

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,

Dilli babu.


CONFIRMATION

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.

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.

;