@@ -32,6 +32,7 @@ class RowSpliterator implements Spliterator<Row> {
32
32
private final HashMap <Integer , BaseFormulaCell > sharedFormula = new HashMap <>();
33
33
private final HashMap <CellRangeAddress , String > arrayFormula = new HashMap <>();
34
34
private int rowCapacity = 16 ;
35
+ private int trackedRowIndex = 0 ;
35
36
36
37
public RowSpliterator (ReadableWorkbook workbook , InputStream inputStream ) throws XMLStreamException {
37
38
this .workbook = workbook ;
@@ -82,7 +83,10 @@ private Row next() throws XMLStreamException {
82
83
if (!"row" .equals (r .getLocalName ())) {
83
84
throw new NoSuchElementException ();
84
85
}
85
- int rowIndex = r .getIntAttribute ("r" );
86
+
87
+ int trackedColIndex = 0 ;
88
+ int rowIndex = getRowIndexWithFallback (++trackedRowIndex );
89
+
86
90
List <Cell > cells = new ArrayList <>(rowCapacity );
87
91
int physicalCellCount = 0 ;
88
92
@@ -91,7 +95,7 @@ private Row next() throws XMLStreamException {
91
95
break ;
92
96
}
93
97
94
- Cell cell = parseCell ();
98
+ Cell cell = parseCell (trackedColIndex ++ );
95
99
CellAddress addr = cell .getAddress ();
96
100
ensureSize (cells , addr .getColumn () + 1 );
97
101
@@ -102,9 +106,20 @@ private Row next() throws XMLStreamException {
102
106
return new Row (rowIndex , physicalCellCount , cells );
103
107
}
104
108
105
- private Cell parseCell () throws XMLStreamException {
106
- String cellRef = r .getAttribute ("r" );
107
- CellAddress addr = new CellAddress (cellRef );
109
+ private int getRowIndexWithFallback (int fallbackRowIndex ) {
110
+ Integer rowIndexOrNull = r .getIntAttribute ("r" );
111
+ return rowIndexOrNull != null ? rowIndexOrNull : fallbackRowIndex ;
112
+ }
113
+
114
+ private CellAddress getCellAddressWithFallback (int trackedColIndex ) {
115
+ String cellRefOrNull = r .getAttribute ("r" );
116
+ return cellRefOrNull != null ?
117
+ new CellAddress (cellRefOrNull ) :
118
+ new CellAddress (trackedRowIndex , trackedColIndex );
119
+ }
120
+
121
+ private Cell parseCell (int trackedColIndex ) throws XMLStreamException {
122
+ CellAddress addr = getCellAddressWithFallback (trackedColIndex );
108
123
String type = r .getOptionalAttribute ("t" ).orElse ("n" );
109
124
String styleString = r .getAttribute ("s" );
110
125
String formatId = null ;
0 commit comments