Browse Source

Fix number formats in workbooks where no custom formats are created

The map wasn't created until the first addFmt was called, which
isn't called for custom formats, which was preventing builtin
formats from being read.
Brian Smith 11 years ago
parent
commit
214a2549ba
1 changed files with 2 additions and 2 deletions
  1. 2 2
      xmlStyle.go

+ 2 - 2
xmlStyle.go

@@ -180,7 +180,7 @@ func getBuiltinNumberFormat(numFmtId int) string {
 }
 
 func (styles *xlsxStyleSheet) getNumberFormat(styleIndex int) string {
-	if styles.CellXfs.Xf == nil || styles.numFmtRefTable == nil {
+	if styles.CellXfs.Xf == nil {
 		return ""
 	}
 	var numberFormat string = ""
@@ -188,7 +188,7 @@ func (styles *xlsxStyleSheet) getNumberFormat(styleIndex int) string {
 		xf := styles.CellXfs.Xf[styleIndex]
 		if xf.NumFmtId < 164 {
 			return getBuiltinNumberFormat(xf.NumFmtId)
-		} else {
+		} else if styles.numFmtRefTable != nil {
 			numFmt := styles.numFmtRefTable[xf.NumFmtId]
 			numberFormat = numFmt.FormatCode
 		}