AutoSizeColumn effects on performance in Apache POI
autoSizeColumn() method of apache poi is used to resize the column according to its content length. The most common mistake is to use this method every time, you write some value in a column. e.g. If I need to write 15k rows in excel and call this method is every cell in that iteration, then it will take you forever to write that file. autoSizeColumn() is clearly too slow if used in writing of each cell and resizing it.
Solution:- Write all the data in excel. Then on final excel call this method once in every column. It will resize the data of a column in one go. You will see a drastic change in performance of writing excel.
autoSizeColumn() method of apache poi is used to resize the column according to its content length. The most common mistake is to use this method every time, you write some value in a column. e.g. If I need to write 15k rows in excel and call this method is every cell in that iteration, then it will take you forever to write that file. autoSizeColumn() is clearly too slow if used in writing of each cell and resizing it.
Solution:- Write all the data in excel. Then on final excel call this method once in every column. It will resize the data of a column in one go. You will see a drastic change in performance of writing excel.
No comments:
Post a Comment