Java POI Excel creating new column and new rows

后端 未结 5 891
慢半拍i
慢半拍i 2021-01-16 05:09

Ok so Im iterating over a list and instead of inserting values into cells horizontally, im putting the values in the cells vertically.

It works fine for the first ti

5条回答
  •  走了就别回头了
    2021-01-16 06:09

    When you iterate through the first list. You have created the rows. The next time when you iterate you have to update the rows instead of creating it again. When you create new row, its going to add at the end.

    When iterating through List1, when you reached at the end you have already created three new rows. If you now make row = 0 and iterate through the second list List2. It is going to add a new row at 0 and so on till it reaches the end of List2.

    If you have not made rows = 0 at the end of the iteration. New rows will be added at the end.

    int row = 0;
    int k = 1; 
    
    ArrayList rows = new ArrayList();
    for(int i = 0; i

提交回复
热议问题