AutoFitRows doesn't work

Hello,

I try to use the AutoFitterOptions for AutoFitRows in my program for autofitting merged cells but while it worked before, with the new version 7.0.1 of Aspose.Cells it seems that it doesn’t work anymore.

Here’s my sample code :
var excel = new Workbook();
excel.Worksheets.Add(“test”);

excel.Worksheets[0].Cells[1, 1].PutValue("blablablba blabalbal test test test test test test test test test test test test ");

//Create the range for the merging cell and for applying the style
var range = excel.Worksheets[0].Cells.CreateRange(1,1,1,2);
range.Merge();

//Applying the text wrapping
var style = excel.Worksheets[0].Cells[1, 1].GetStyle();
style.IsTextWrapped = true;
var flag = new StyleFlag { All = true };
range.ApplyStyle(style, flag);

//Using the autofit with the options for the merged cells
var options = new AutoFitterOptions { AutoFitMergedCells = true };
excel.Worksheets[0].AutoFitRows(options);

excel.Save(“testExcel.xls”);

Thanks in advance for the help

Hi,


Thanks for reporting the issue.

I have tested your issue with your code and I found the issue as you mentioned. I even tried my another code segment but the result is the same.

Code Segments:
1)
var excel = new Workbook();
excel.Worksheets.Add(“test”);

excel.Worksheets[0].Cells[1, 1].PutValue("blablablba blabalbal test test test test test test test test test test test test end ");

//Create the range for the merging cell and for applying the style
var range = excel.Worksheets[0].Cells.CreateRange(1, 1, 1, 2);
range.Merge();

//Applying the text wrapping
var style = excel.Worksheets[0].Cells[1, 1].GetStyle();
style.IsTextWrapped = true;
var flag = new StyleFlag { All = true };
range.ApplyStyle(style, flag);

//Using the autofit with the options for the merged cells
var options = new AutoFitterOptions { AutoFitMergedCells = true };
excel.Worksheets[0].AutoFitRows(options);

excel.Save(“e:\test2\out1.xls”);


2)
//Instantiate a new Workbook
Workbook wb = new Workbook();
//Get the first (default) worksheet
Worksheet _worksheet = wb.Worksheets[0];
//Create a range A1:B1
Range range = _worksheet.Cells.CreateRange(0, 0, 1, 2);
//Merge the cells
range.Merge();
//Insert value to the merged cell A1
_worksheet.Cells[0, 0].Value = “A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog…end”;
//Create a style object
Aspose.Cells.Style style = _worksheet.Cells[0, 0].GetStyle();
//Set wrapping text on
style.IsTextWrapped = true;
//Apply the style to the cell
_worksheet.Cells[0, 0].SetStyle(style);

//Create an object for AutoFitterOptions
AutoFitterOptions options = new AutoFitterOptions();
//Set auto-fit for merged cells
options.AutoFitMergedCells = true;

//Autofit rows in the sheet(including the merged cells)
_worksheet.AutoFitRows(options);

//Save the Excel file
wb.Save(“e:\test2\out2.xlsx”);

I have logged a ticket for the issue with an id: CELLSNET-31095. We will figure it out soon.

Thank you.

Hi,

We have fixed this issue. Please download: Aspose.Cells for .NET v7.0.1.6

The issues you have found earlier (filed as 31095) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.