@@ -235,22 +235,22 @@ private int fillData(
235
235
Sheet sheet , Cell dataCell , DataProvider <T , ?> dataProvider , CellRangeAddress dataRange , boolean titleExists ) {
236
236
Stream <T > dataStream = obtainDataStream (dataProvider );
237
237
238
- boolean [] notFirstRow = new boolean [ 1 ] ;
239
- Cell [] startingCell = new Cell [ 1 ] ;
240
- startingCell [ 0 ] = dataCell ;
241
- dataStream . forEach (
242
- t -> {
243
- if (notFirstRow [ 0 ] ) {
244
- CellStyle cellStyle = startingCell [ 0 ] .getCellStyle ();
245
- Row newRow = sheet .createRow (startingCell [ 0 ] .getRowIndex () + 1 );
246
- startingCell [ 0 ] = newRow .createCell (startingCell [ 0 ] .getColumnIndex ());
247
- startingCell [ 0 ] .setCellStyle (cellStyle );
248
- }
249
- // update the data range by updating last row
250
- dataRange .setLastRow (dataRange .getLastRow () + 1 );
251
- buildRow (t , sheet , startingCell [ 0 ] );
252
- notFirstRow [ 0 ] = true ;
253
- });
238
+ boolean notFirstRow = false ;
239
+ Cell startingCell = dataCell ;
240
+
241
+ Iterable < T > items = dataStream :: iterator ;
242
+ for ( T item : items ) {
243
+ if (notFirstRow ) {
244
+ CellStyle cellStyle = startingCell .getCellStyle ();
245
+ Row newRow = sheet .createRow (startingCell .getRowIndex () + 1 );
246
+ startingCell = newRow .createCell (startingCell .getColumnIndex ());
247
+ startingCell .setCellStyle (cellStyle );
248
+ }
249
+ // update the data range by updating last row
250
+ dataRange .setLastRow (dataRange .getLastRow () + 1 );
251
+ buildRow (item , sheet , startingCell );
252
+ notFirstRow = true ;
253
+ }
254
254
// since we initialized the cell range with the data placeholder cell, we use
255
255
// the existing 'getLastColumn' to keep the offset of the data range
256
256
dataRange .setLastColumn (dataRange .getLastColumn () + exporter .getColumns ().size () - 1 );
0 commit comments