A POI related code block running dead slow

后端 未结 3 679
再見小時候
再見小時候 2020-12-20 08:23

I have below piece of code block containing loops:

Row row = null;
Cell cell = null;
String dataVal = null;
String[] temp = null;

for (int j = 0; j < thi         


        
3条回答
  •  礼貌的吻别
    2020-12-20 08:52

    Your processing is very slow because you're calling autoSizeColumn for every row. From the Javadocs for the autoSizeColumn method:

    This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.

    Place the calls to autoSizeColumn outside of the loop that creates the rows, in its own for loop only on the columns. This will minimize calls to this method and improve your performance.

提交回复
热议问题