Преглед на файлове

Extend panic fix to guard insertColIndex also.

James Welch преди 9 години
родител
ревизия
4b65721dac
променени са 1 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 6 3
      lib.go

+ 6 - 3
lib.go

@@ -577,17 +577,20 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File, sheet *Sheet) ([]*R
 			}
 			x, _, _ := getCoordsFromCellIDString(rawcell.R)
 
+			// K1000000: Prevent panic when the range specified in the spreadsheet
+			//           view exceeds the actual number of columns in the dataset.
+
 			// Some spreadsheets will omit blank cells
 			// from the data.
 			for x > insertColIndex {
 				// Put an empty Cell into the array
-				row.Cells[insertColIndex] = new(Cell)
+				if insertColIndex < len(row.Cells) {
+					row.Cells[insertColIndex] = new(Cell)
+				}
 				insertColIndex++
 			}
 			cellX := insertColIndex
 
-			// K1000000: Prevent panic when the range specified in the spreadsheet
-			//           view exceeds the actual number of columns in the dataset.
 			if cellX < len(row.Cells) {
 				cell := row.Cells[cellX]
 				cell.HMerge = h