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

Free Support Forum - aspose.com

Performance of auto-fit columns functions for MS Excel worksheet

Hi,

We have problem, the original excel file has smaller width column which cause cell content display in multiple lines , result in alignment issue in our application.

Call
Worksheet worksheet = xxxxxxxxx;
worksheet.autoFitColumns();

this fix the problem, however performance is very slow. We should not call worksheet.autoFitColumns() until it is needed.

Could you provide some sample code to demo when ( the original excel file has smaller width column which cause cell content display in multiple lines , in our case) should call autoFitColumn?

Many thanks!

Ruhong

@ruhongcai,
Thank you for your query. We are analysing your requirement and will share the feedback soon.

@ruhongcai,

Well, auto-fit rows/cols operation(s) might affect the performance where there are lots of data in rows and columns. I guess you should simply extend the width of the specified column(s) a bit using Cells.setColumnWidthxxx method rather than using auto-fit columns operation for whole sheet. This will not affect much related to performance. You may use Cells.getColumnWidthxxx() method to get the width of a column and if it has smaller width, you may extend the width accordingly. Even you may call Worksheet.autoFitColumn method (instead of Worksheet.autoFitColumns) upon the column with smaller widths.

Hope, this helps a bit.