Browse Source

* lib.go: handle empty cells

Geoffrey Teale 14 years ago
parent
commit
a0b92bcaee
1 changed files with 7 additions and 4 deletions
  1. 7 4
      lib.go

+ 7 - 4
lib.go

@@ -69,11 +69,14 @@ func readRowsFromSheet(worksheet *XLSXWorksheet, reftable []string) []*Row {
 		row.Cells = make([]*Cell, len(rawrow.C))
 		row.Cells = make([]*Cell, len(rawrow.C))
 		for j, rawcell := range rawrow.C {
 		for j, rawcell := range rawrow.C {
 			cell := new(Cell)
 			cell := new(Cell)
-			ref, error := strconv.Atoi(rawcell.V.Data)
-			if error != nil {
-				panic(fmt.Sprintf("Invalid reference in Excel Cell (not found in sharedStrings.xml) - the reference was %v\n", rawcell.V.Data))
+			cell.data = ""
+			if len(rawcell.V.Data) > 0 {
+				ref, error := strconv.Atoi(rawcell.V.Data)
+				if error != nil {
+					panic(fmt.Sprintf("Invalid reference in Excel Cell (not found in sharedStrings.xml) - the reference was %v\n", rawcell.V.Data))
+				}
+				cell.data = reftable[ref]
 			}
 			}
-			cell.data = reftable[ref]
 			row.Cells[j] = cell
 			row.Cells[j] = cell
 		}
 		}
 		rows[i] = row
 		rows[i] = row