I try to apply autoSizeColumn on an Excel sheet. I'm using POI 3.10.1.
I apply autoSizeColumn at the end but the problem is than the process is too slow/long anyway:
On the sheet I've approximately 1000 lines and 20 columns... After 5 hours, I kill the process ...
I don't understand what is taking so long, 1000 lines and 20 columns doesn't appear so huge: Did I miss something? (nb: on a smaller file, it's working)
My simplified code below:
Workbook vWorkbook = getWorkbook();
Sheet vSheet = vWorkbook.createSheet("sheet");
CreationHelper vHelper = vWorkbook.getCreationHelper();
Drawing drawing = vSheet.createDrawingPatriarch();
Set<CellRangeAddress> vRegions = new HashSet<CellRangeAddress>();
//Parcours des lignes du document
MatrixDocument vMatrixDocument = getMatrixDocument();
List<MatrixRow> vListMatrixRows = vMatrixDocument.getRows();
int maxColNb = 0;
//Parcours des lignes de la grille.
for (MatrixRow vMatrixRow : vListMatrixRows)
{
//(...)
//create cells
//(...)
}
initColSpan(vListMatrixRows, vRegions);
//Gestion des colSpan et des RowSpan
for (CellRangeAddress vRegion : vRegions)
{
vSheet.addMergedRegion(vRegion);
}
for (int i = 0; i < maxColNb; ++i)
{
vSheet.autoSizeColumn(i, true);//Here the problem. spent more than 5 hour for 1000 lines and 20 columns
}
I've already read threads below :
- http://stackoverflow.com/questions/16943493/apache-poi-autosizecolumn-resizes-incorrectly
- http://stackoverflow.com/questions/15740100/apache-poi-autosizecolumn-not-working-right
- http://stackoverflow.com/questions/23366606/autosizecolumn-performance-effect-in-apache-poi
- http://stackoverflow.com/questions/18984785/a-poi-related-code-block-running-dead-slow
- http://stackoverflow.com/questions/28564045/apache-poi-autosizecolumn-behaving-weird
- http://stackoverflow.com/questions/18456474/apache-poi-autosizecolumn-is-not-working
But none solve my issue.
Any idea ?
PS : I tried to upload an example image of the Excel file but I don't find how to upload it.