summaryrefslogtreecommitdiff
path: root/stream.go
diff options
context:
space:
mode:
Diffstat (limited to 'stream.go')
-rw-r--r--stream.go38
1 files changed, 26 insertions, 12 deletions
diff --git a/stream.go b/stream.go
index aaa4589..fa78d8b 100644
--- a/stream.go
+++ b/stream.go
@@ -263,7 +263,7 @@ func (sw *StreamWriter) getRowValues(hRow, hCol, vCol int) (res []string, err er
if col < hCol || col > vCol {
continue
}
- res[col-hCol] = c.V
+ res[col-hCol], _ = c.getValueFrom(sw.File, nil, false)
}
return res, nil
}
@@ -462,7 +462,7 @@ func (sw *StreamWriter) MergeCell(hCell, vCell string) error {
// setCellFormula provides a function to set formula of a cell.
func setCellFormula(c *xlsxC, formula string) {
if formula != "" {
- c.F = &xlsxF{Content: formula}
+ c.T, c.F = "str", &xlsxF{Content: formula}
}
}
@@ -477,9 +477,9 @@ func (sw *StreamWriter) setCellValFunc(c *xlsxC, val interface{}) error {
case float64:
c.T, c.V = setCellFloat(val, -1, 64)
case string:
- c.T, c.V, c.XMLSpace = setCellStr(val)
+ c.setCellValue(val)
case []byte:
- c.T, c.V, c.XMLSpace = setCellStr(string(val))
+ c.setCellValue(string(val))
case time.Duration:
c.T, c.V = setCellDuration(val)
case time.Time:
@@ -488,20 +488,19 @@ func (sw *StreamWriter) setCellValFunc(c *xlsxC, val interface{}) error {
if wb != nil && wb.WorkbookPr != nil {
date1904 = wb.WorkbookPr.Date1904
}
- c.T, c.V, isNum, err = setCellTime(val, date1904)
- if isNum && c.S == 0 {
+ if isNum, err = c.setCellTime(val, date1904); isNum && c.S == 0 {
style, _ := sw.File.NewStyle(&Style{NumFmt: 22})
c.S = style
}
case bool:
c.T, c.V = setCellBool(val)
case nil:
- c.T, c.V, c.XMLSpace = setCellStr("")
+ c.setCellValue("")
case []RichTextRun:
c.T, c.IS = "inlineStr", &xlsxSI{}
c.IS.R, err = setRichText(val)
default:
- c.T, c.V, c.XMLSpace = setCellStr(fmt.Sprint(val))
+ c.setCellValue(fmt.Sprint(val))
}
return err
}
@@ -569,10 +568,25 @@ func writeCell(buf *bufferedWriter, c xlsxC) {
_, _ = buf.WriteString(`</v>`)
}
if c.IS != nil {
- is, _ := xml.Marshal(c.IS.R)
- _, _ = buf.WriteString(`<is>`)
- _, _ = buf.Write(is)
- _, _ = buf.WriteString(`</is>`)
+ if len(c.IS.R) > 0 {
+ is, _ := xml.Marshal(c.IS.R)
+ _, _ = buf.WriteString(`<is>`)
+ _, _ = buf.Write(is)
+ _, _ = buf.WriteString(`</is>`)
+ }
+ if c.IS.T != nil {
+ _, _ = buf.WriteString(`<is><t`)
+ if c.IS.T.Space.Value != "" {
+ _, _ = buf.WriteString(` xml:`)
+ _, _ = buf.WriteString(c.IS.T.Space.Name.Local)
+ _, _ = buf.WriteString(`="`)
+ _, _ = buf.WriteString(c.IS.T.Space.Value)
+ _, _ = buf.WriteString(`"`)
+ }
+ _, _ = buf.WriteString(`>`)
+ _, _ = buf.Write([]byte(c.IS.T.Val))
+ _, _ = buf.WriteString(`</t></is>`)
+ }
}
_, _ = buf.WriteString(`</c>`)
}