Browse Source

Fix for multiple ranges in a row

Some row has two ranges in spans, for example:
  <row ... spans="1:10 6802:6802">

This xlsx file causes following panic:
  panic: Invalid range (not integer in upper bound) 1:10 6802:6802

Changes:
 * Call makeRowFromRaw instead of makeRowFromSpan
   when spans has 0 or 2 or more ":"
YAMADA Tsuyoshi 11 years ago
parent
commit
bf59f69ef3
1 changed files with 2 additions and 2 deletions
  1. 2 2
      lib.go

+ 2 - 2
lib.go

@@ -372,8 +372,8 @@ func readRowsFromSheet(Worksheet *xlsxWorksheet, file *File) ([]*Row, int, int)
 			rows[insertRowIndex-minRow] = new(Row)
 			rows[insertRowIndex-minRow] = new(Row)
 			insertRowIndex++
 			insertRowIndex++
 		}
 		}
-		// range is not empty
-		if len(rawrow.Spans) != 0 {
+		// range is not empty and only one range exist
+		if len(rawrow.Spans) != 0 && strings.Count(rawrow.Spans, ":") == 1 {
 			row = makeRowFromSpan(rawrow.Spans)
 			row = makeRowFromSpan(rawrow.Spans)
 		} else {
 		} else {
 			row = makeRowFromRaw(rawrow)
 			row = makeRowFromRaw(rawrow)