We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Autofitrows making rows way too large

Hi,

Autofitrows is working for me in the most technical sense. However, the rows are about double as wide as they need to be. Is there a font or other trick that I can use to get autofitrows to perform a near approximation to what excel 2007 renders?

If not has anyone computed row highs themselves based on cell value length and column widths?

Thanks,

Dean

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Well, we are not very clear about the issue you are getting in the autofit rows. We will really appreciate if you can share your Excel 2007 template file, so we can figure out the exact issue and provide you with an appropriate solution.

Thank You & Best Regards,

I have attached a sample. Column B has istextwrapped set. I call autofitrows after generating all the output. Note how wide the rows become. Even rows where the column B text fits on the row without wrapping the rode is widened.

Ex. Row 7 has a hight of 25.5, I would expect a row hight of 12.75

Since I am using the results in a printed report I cannot get away with all the wasted space. Once the sheet is constructed, the first thing I do is turn it into a pdf. What I do notice is that if I reduce the width of what autofitrows generates by half then it is very close to a perfect fit. I have not tested this assumption heavily.

Thanks,

Dean

Hi Dean,

Thanks for sharing your template xlsx file.

Well, I have tested Worksheet.AutoFitRows, it works just fine similar to MS Excel 2007 feature. I have also tested it with your file using the following codes, the output file just fine with all the rows are auto-fitted (the output file is also attached).

Sample code:

Workbook workbook = new Workbook();
workbook.Open("f:\\test\\sampleForAspose.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
worksheet.AutoFitRows();
workbook.Save("f:\\test\\noutsampleForAspose.xlsx",FileFormatType.Excel2007Xlsx);

I think you are using some older version of the product, Could you try the attached latest version/fix.

If you still find the issue, kindly do post your sample code to generate the file, we will check it soon.

Thank you.