This closes #1523, preventing format text cell value as a numeric

- Simplify variable declaration and error return statements
- Remove the internal `xlsxTabColor` data type
- Using the `xlsxColor` data type instead of `xlsxTabColor`
- Update unit test, improve code coverage
This commit is contained in:
xuri 2023-04-19 00:05:59 +08:00
parent d0ad0f39ec
commit fb6ce60bd5
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
14 changed files with 400 additions and 354 deletions

View File

@ -791,11 +791,11 @@ func (f *File) CalcCellValue(sheet, cell string, opts ...Options) (result string
result = token.Value() result = token.Value()
if isNum, precision, decimal := isNumeric(result); isNum { if isNum, precision, decimal := isNumeric(result); isNum {
if precision > 15 { if precision > 15 {
result, err = f.formattedValue(styleIdx, strings.ToUpper(strconv.FormatFloat(decimal, 'G', 15, 64)), rawCellValue) result, err = f.formattedValue(&xlsxC{S: styleIdx, V: strings.ToUpper(strconv.FormatFloat(decimal, 'G', 15, 64))}, rawCellValue, CellTypeNumber)
return return
} }
if !strings.HasPrefix(result, "0") { if !strings.HasPrefix(result, "0") {
result, err = f.formattedValue(styleIdx, strings.ToUpper(strconv.FormatFloat(decimal, 'f', -1, 64)), rawCellValue) result, err = f.formattedValue(&xlsxC{S: styleIdx, V: strings.ToUpper(strconv.FormatFloat(decimal, 'f', -1, 64))}, rawCellValue, CellTypeNumber)
} }
} }
return return

50
cell.go
View File

@ -516,7 +516,7 @@ func (c *xlsxC) getCellBool(f *File, raw bool) (string, error) {
return "FALSE", nil return "FALSE", nil
} }
} }
return f.formattedValue(c.S, c.V, raw) return f.formattedValue(c, raw, CellTypeBool)
} }
// setCellDefault prepares cell type and string type cell value by a given // setCellDefault prepares cell type and string type cell value by a given
@ -551,7 +551,7 @@ func (c *xlsxC) getCellDate(f *File, raw bool) (string, error) {
c.V = strconv.FormatFloat(excelTime, 'G', 15, 64) c.V = strconv.FormatFloat(excelTime, 'G', 15, 64)
} }
} }
return f.formattedValue(c.S, c.V, raw) return f.formattedValue(c, raw, CellTypeBool)
} }
// getValueFrom return a value from a column/row cell, this function is // getValueFrom return a value from a column/row cell, this function is
@ -567,21 +567,20 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST, raw bool) (string, error) {
return c.getCellDate(f, raw) return c.getCellDate(f, raw)
case "s": case "s":
if c.V != "" { if c.V != "" {
xlsxSI := 0 xlsxSI, _ := strconv.Atoi(strings.TrimSpace(c.V))
xlsxSI, _ = strconv.Atoi(strings.TrimSpace(c.V))
if _, ok := f.tempFiles.Load(defaultXMLPathSharedStrings); ok { if _, ok := f.tempFiles.Load(defaultXMLPathSharedStrings); ok {
return f.formattedValue(c.S, f.getFromStringItem(xlsxSI), raw) return f.formattedValue(&xlsxC{S: c.S, V: f.getFromStringItem(xlsxSI)}, raw, CellTypeSharedString)
} }
if len(d.SI) > xlsxSI { if len(d.SI) > xlsxSI {
return f.formattedValue(c.S, d.SI[xlsxSI].String(), raw) return f.formattedValue(&xlsxC{S: c.S, V: d.SI[xlsxSI].String()}, raw, CellTypeSharedString)
} }
} }
return f.formattedValue(c.S, c.V, raw) return f.formattedValue(c, raw, CellTypeSharedString)
case "inlineStr": case "inlineStr":
if c.IS != nil { if c.IS != nil {
return f.formattedValue(c.S, c.IS.String(), raw) return f.formattedValue(&xlsxC{S: c.S, V: c.IS.String()}, raw, CellTypeInlineString)
} }
return f.formattedValue(c.S, c.V, raw) return f.formattedValue(c, raw, CellTypeInlineString)
default: default:
if isNum, precision, decimal := isNumeric(c.V); isNum && !raw { if isNum, precision, decimal := isNumeric(c.V); isNum && !raw {
if precision > 15 { if precision > 15 {
@ -590,7 +589,7 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST, raw bool) (string, error) {
c.V = strconv.FormatFloat(decimal, 'f', -1, 64) c.V = strconv.FormatFloat(decimal, 'f', -1, 64)
} }
} }
return f.formattedValue(c.S, c.V, raw) return f.formattedValue(c, raw, CellTypeNumber)
} }
} }
@ -1325,47 +1324,44 @@ func (f *File) getCellStringFunc(sheet, cell string, fn func(x *xlsxWorksheet, c
// formattedValue provides a function to returns a value after formatted. If // formattedValue provides a function to returns a value after formatted. If
// it is possible to apply a format to the cell value, it will do so, if not // it is possible to apply a format to the cell value, it will do so, if not
// then an error will be returned, along with the raw value of the cell. // then an error will be returned, along with the raw value of the cell.
func (f *File) formattedValue(s int, v string, raw bool) (string, error) { func (f *File) formattedValue(c *xlsxC, raw bool, cellType CellType) (string, error) {
if raw { if raw || c.S == 0 {
return v, nil return c.V, nil
}
if s == 0 {
return v, nil
} }
styleSheet, err := f.stylesReader() styleSheet, err := f.stylesReader()
if err != nil { if err != nil {
return v, err return c.V, err
} }
if styleSheet.CellXfs == nil { if styleSheet.CellXfs == nil {
return v, err return c.V, err
} }
if s >= len(styleSheet.CellXfs.Xf) || s < 0 { if c.S >= len(styleSheet.CellXfs.Xf) || c.S < 0 {
return v, err return c.V, err
} }
var numFmtID int var numFmtID int
if styleSheet.CellXfs.Xf[s].NumFmtID != nil { if styleSheet.CellXfs.Xf[c.S].NumFmtID != nil {
numFmtID = *styleSheet.CellXfs.Xf[s].NumFmtID numFmtID = *styleSheet.CellXfs.Xf[c.S].NumFmtID
} }
date1904 := false date1904 := false
wb, err := f.workbookReader() wb, err := f.workbookReader()
if err != nil { if err != nil {
return v, err return c.V, err
} }
if wb != nil && wb.WorkbookPr != nil { if wb != nil && wb.WorkbookPr != nil {
date1904 = wb.WorkbookPr.Date1904 date1904 = wb.WorkbookPr.Date1904
} }
if ok := builtInNumFmtFunc[numFmtID]; ok != nil { if ok := builtInNumFmtFunc[numFmtID]; ok != nil {
return ok(v, builtInNumFmt[numFmtID], date1904), err return ok(c.V, builtInNumFmt[numFmtID], date1904, cellType), err
} }
if styleSheet.NumFmts == nil { if styleSheet.NumFmts == nil {
return v, err return c.V, err
} }
for _, xlsxFmt := range styleSheet.NumFmts.NumFmt { for _, xlsxFmt := range styleSheet.NumFmts.NumFmt {
if xlsxFmt.NumFmtID == numFmtID { if xlsxFmt.NumFmtID == numFmtID {
return format(v, xlsxFmt.FormatCode, date1904), err return format(c.V, xlsxFmt.FormatCode, date1904, cellType), err
} }
} }
return v, err return c.V, err
} }
// prepareCellStyle provides a function to prepare style index of cell in // prepareCellStyle provides a function to prepare style index of cell in

View File

@ -803,21 +803,21 @@ func TestSetCellRichText(t *testing.T) {
func TestFormattedValue(t *testing.T) { func TestFormattedValue(t *testing.T) {
f := NewFile() f := NewFile()
result, err := f.formattedValue(0, "43528", false) result, err := f.formattedValue(&xlsxC{S: 0, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
// S is too large // S is too large
result, err = f.formattedValue(15, "43528", false) result, err = f.formattedValue(&xlsxC{S: 15, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
// S is too small // S is too small
result, err = f.formattedValue(-15, "43528", false) result, err = f.formattedValue(&xlsxC{S: -15, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
result, err = f.formattedValue(1, "43528", false) result, err = f.formattedValue(&xlsxC{S: 1, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
customNumFmt := "[$-409]MM/DD/YYYY" customNumFmt := "[$-409]MM/DD/YYYY"
@ -825,7 +825,7 @@ func TestFormattedValue(t *testing.T) {
CustomNumFmt: &customNumFmt, CustomNumFmt: &customNumFmt,
}) })
assert.NoError(t, err) assert.NoError(t, err)
result, err = f.formattedValue(1, "43528", false) result, err = f.formattedValue(&xlsxC{S: 1, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "03/04/2019", result) assert.Equal(t, "03/04/2019", result)
@ -834,7 +834,7 @@ func TestFormattedValue(t *testing.T) {
f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{ f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{
NumFmtID: &numFmtID, NumFmtID: &numFmtID,
}) })
result, err = f.formattedValue(2, "43528", false) result, err = f.formattedValue(&xlsxC{S: 2, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
@ -842,7 +842,7 @@ func TestFormattedValue(t *testing.T) {
f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{ f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{
NumFmtID: nil, NumFmtID: nil,
}) })
result, err = f.formattedValue(3, "43528", false) result, err = f.formattedValue(&xlsxC{S: 3, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
@ -851,7 +851,16 @@ func TestFormattedValue(t *testing.T) {
f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{ f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{
NumFmtID: &numFmtID, NumFmtID: &numFmtID,
}) })
result, err = f.formattedValue(1, "43528", false) result, err = f.formattedValue(&xlsxC{S: 1, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err)
assert.Equal(t, "43528", result)
// Test format numeric value with shared string data type
f.Styles.NumFmts, numFmtID = nil, 11
f.Styles.CellXfs.Xf = append(f.Styles.CellXfs.Xf, xlsxXf{
NumFmtID: &numFmtID,
})
result, err = f.formattedValue(&xlsxC{S: 5, V: "43528"}, false, CellTypeSharedString)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
@ -860,32 +869,36 @@ func TestFormattedValue(t *testing.T) {
NumFmt: 1, NumFmt: 1,
}) })
assert.NoError(t, err) assert.NoError(t, err)
result, err = f.formattedValue(styleID, "310.56", false) result, err = f.formattedValue(&xlsxC{S: styleID, V: "310.56"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "311", result) assert.Equal(t, "311", result)
for _, fn := range builtInNumFmtFunc { for _, fn := range builtInNumFmtFunc {
assert.Equal(t, "0_0", fn("0_0", "", false)) assert.Equal(t, "0_0", fn("0_0", "", false, CellTypeNumber))
} }
// Test format value with unsupported charset workbook // Test format value with unsupported charset workbook
f.WorkBook = nil f.WorkBook = nil
f.Pkg.Store(defaultXMLPathWorkbook, MacintoshCyrillicCharset) f.Pkg.Store(defaultXMLPathWorkbook, MacintoshCyrillicCharset)
_, err = f.formattedValue(1, "43528", false) _, err = f.formattedValue(&xlsxC{S: 1, V: "43528"}, false, CellTypeNumber)
assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8") assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8")
// Test format value with unsupported charset style sheet // Test format value with unsupported charset style sheet
f.Styles = nil f.Styles = nil
f.Pkg.Store(defaultXMLPathStyles, MacintoshCyrillicCharset) f.Pkg.Store(defaultXMLPathStyles, MacintoshCyrillicCharset)
_, err = f.formattedValue(1, "43528", false) _, err = f.formattedValue(&xlsxC{S: 1, V: "43528"}, false, CellTypeNumber)
assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8") assert.EqualError(t, err, "XML syntax error on line 1: invalid UTF-8")
for _, fn := range builtInNumFmtFunc {
assert.Equal(t, fn("text", "0", false, CellTypeNumber), "text")
}
} }
func TestFormattedValueNilXfs(t *testing.T) { func TestFormattedValueNilXfs(t *testing.T) {
// Set the CellXfs to nil and verify that the formattedValue function does not crash // Set the CellXfs to nil and verify that the formattedValue function does not crash
f := NewFile() f := NewFile()
f.Styles.CellXfs = nil f.Styles.CellXfs = nil
result, err := f.formattedValue(3, "43528", false) result, err := f.formattedValue(&xlsxC{S: 3, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
} }
@ -894,7 +907,7 @@ func TestFormattedValueNilNumFmts(t *testing.T) {
// Set the NumFmts value to nil and verify that the formattedValue function does not crash // Set the NumFmts value to nil and verify that the formattedValue function does not crash
f := NewFile() f := NewFile()
f.Styles.NumFmts = nil f.Styles.NumFmts = nil
result, err := f.formattedValue(3, "43528", false) result, err := f.formattedValue(&xlsxC{S: 3, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
} }
@ -903,7 +916,7 @@ func TestFormattedValueNilWorkbook(t *testing.T) {
// Set the Workbook value to nil and verify that the formattedValue function does not crash // Set the Workbook value to nil and verify that the formattedValue function does not crash
f := NewFile() f := NewFile()
f.WorkBook = nil f.WorkBook = nil
result, err := f.formattedValue(3, "43528", false) result, err := f.formattedValue(&xlsxC{S: 3, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
} }
@ -913,7 +926,7 @@ func TestFormattedValueNilWorkbookPr(t *testing.T) {
// crash. // crash.
f := NewFile() f := NewFile()
f.WorkBook.WorkbookPr = nil f.WorkBook.WorkbookPr = nil
result, err := f.formattedValue(3, "43528", false) result, err := f.formattedValue(&xlsxC{S: 3, V: "43528"}, false, CellTypeNumber)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "43528", result) assert.Equal(t, "43528", result)
} }

View File

@ -121,6 +121,12 @@ func TestDeleteDrawing(t *testing.T) {
path := "xl/drawings/drawing1.xml" path := "xl/drawings/drawing1.xml"
f.Pkg.Store(path, MacintoshCyrillicCharset) f.Pkg.Store(path, MacintoshCyrillicCharset)
assert.EqualError(t, f.deleteDrawing(0, 0, path, "Chart"), "XML syntax error on line 1: invalid UTF-8") assert.EqualError(t, f.deleteDrawing(0, 0, path, "Chart"), "XML syntax error on line 1: invalid UTF-8")
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
assert.NoError(t, err)
f.Drawings.Store(path, &xlsxWsDr{TwoCellAnchor: []*xdrCellAnchor{{
GraphicFrame: string(MacintoshCyrillicCharset),
}}})
assert.EqualError(t, f.deleteDrawing(0, 0, path, "Chart"), "XML syntax error on line 1: invalid UTF-8")
} }
func TestAddChart(t *testing.T) { func TestAddChart(t *testing.T) {

View File

@ -12,11 +12,14 @@
package excelize package excelize
import ( import (
"bytes"
"encoding/binary"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"github.com/richardlehane/mscfb"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -51,6 +54,25 @@ func TestEncrypt(t *testing.T) {
// Test remove password by save workbook with options // Test remove password by save workbook with options
assert.NoError(t, f.Save(Options{Password: ""})) assert.NoError(t, f.Save(Options{Password: ""}))
assert.NoError(t, f.Close()) assert.NoError(t, f.Close())
doc, err := mscfb.New(bytes.NewReader(raw))
assert.NoError(t, err)
encryptionInfoBuf, encryptedPackageBuf := extractPart(doc)
binary.LittleEndian.PutUint64(encryptionInfoBuf[20:32], uint64(0))
_, err = standardDecrypt(encryptionInfoBuf, encryptedPackageBuf, &Options{Password: "password"})
assert.NoError(t, err)
_, err = decrypt(nil, nil, nil)
assert.EqualError(t, err, "crypto/aes: invalid key size 0")
_, err = agileDecrypt(encryptionInfoBuf, MacintoshCyrillicCharset, &Options{Password: "password"})
assert.EqualError(t, err, "XML syntax error on line 1: invalid character entity &0 (no semicolon)")
_, err = convertPasswdToKey("password", nil, Encryption{
KeyEncryptors: KeyEncryptors{KeyEncryptor: []KeyEncryptor{
{EncryptedKey: EncryptedKey{KeyData: KeyData{SaltValue: "=="}}},
}},
})
assert.EqualError(t, err, "illegal base64 data at input byte 0")
_, err = createIV([]byte{0}, Encryption{KeyData: KeyData{SaltValue: "=="}})
assert.EqualError(t, err, "illegal base64 data at input byte 0")
} }
func TestEncryptionMechanism(t *testing.T) { func TestEncryptionMechanism(t *testing.T) {

View File

@ -101,11 +101,10 @@ func OpenFile(filename string, opts ...Options) (*File, error) {
} }
f, err := OpenReader(file, opts...) f, err := OpenReader(file, opts...)
if err != nil { if err != nil {
closeErr := file.Close() if closeErr := file.Close(); closeErr != nil {
if closeErr == nil { return f, closeErr
return f, err
} }
return f, closeErr return f, err
} }
f.Path = filename f.Path = filename
return f, file.Close() return f, file.Close()

View File

@ -31,6 +31,7 @@ type languageInfo struct {
// numberFormat directly maps the number format parser runtime required // numberFormat directly maps the number format parser runtime required
// fields. // fields.
type numberFormat struct { type numberFormat struct {
cellType CellType
section []nfp.Section section []nfp.Section
t time.Time t time.Time
sectionIdx int sectionIdx int
@ -336,6 +337,9 @@ var (
// prepareNumberic split the number into two before and after parts by a // prepareNumberic split the number into two before and after parts by a
// decimal point. // decimal point.
func (nf *numberFormat) prepareNumberic(value string) { func (nf *numberFormat) prepareNumberic(value string) {
if nf.cellType != CellTypeNumber && nf.cellType != CellTypeDate {
return
}
if nf.isNumeric, _, _ = isNumeric(value); !nf.isNumeric { if nf.isNumeric, _, _ = isNumeric(value); !nf.isNumeric {
return return
} }
@ -344,9 +348,9 @@ func (nf *numberFormat) prepareNumberic(value string) {
// format provides a function to return a string parse by number format // format provides a function to return a string parse by number format
// expression. If the given number format is not supported, this will return // expression. If the given number format is not supported, this will return
// the original cell value. // the original cell value.
func format(value, numFmt string, date1904 bool) string { func format(value, numFmt string, date1904 bool, cellType CellType) string {
p := nfp.NumberFormatParser() p := nfp.NumberFormatParser()
nf := numberFormat{section: p.Parse(numFmt), value: value, date1904: date1904} nf := numberFormat{section: p.Parse(numFmt), value: value, date1904: date1904, cellType: cellType}
nf.number, nf.valueSectionType = nf.getValueSectionType(value) nf.number, nf.valueSectionType = nf.getValueSectionType(value)
nf.prepareNumberic(value) nf.prepareNumberic(value)
for i, section := range nf.section { for i, section := range nf.section {
@ -947,7 +951,7 @@ func (nf *numberFormat) textHandler() (result string) {
if token.TType == nfp.TokenTypeLiteral { if token.TType == nfp.TokenTypeLiteral {
result += token.TValue result += token.TValue
} }
if token.TType == nfp.TokenTypeTextPlaceHolder { if token.TType == nfp.TokenTypeTextPlaceHolder || token.TType == nfp.TokenTypeZeroPlaceHolder {
result += nf.value result += nf.value
} }
} }

View File

@ -1005,7 +1005,7 @@ func TestNumFmt(t *testing.T) {
{"-8.0450685976001E-21", "0_);[Red]\\(0\\)", "(0)"}, {"-8.0450685976001E-21", "0_);[Red]\\(0\\)", "(0)"},
{"-8.04506", "0_);[Red]\\(0\\)", "(8)"}, {"-8.04506", "0_);[Red]\\(0\\)", "(8)"},
} { } {
result := format(item[0], item[1], false) result := format(item[0], item[1], false, CellTypeNumber)
assert.Equal(t, item[2], result, item) assert.Equal(t, item[2], result, item)
} }
} }

View File

@ -11,6 +11,16 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestGetRows(t *testing.T) {
f := NewFile()
assert.NoError(t, f.SetCellValue("Sheet1", "A1", "A1"))
// Test get rows with unsupported charset shared strings table
f.SharedStrings = nil
f.Pkg.Store(defaultXMLPathSharedStrings, MacintoshCyrillicCharset)
_, err := f.GetRows("Sheet1")
assert.NoError(t, err)
}
func TestRows(t *testing.T) { func TestRows(t *testing.T) {
const sheet2 = "Sheet2" const sheet2 = "Sheet2"
f, err := OpenFile(filepath.Join("test", "Book1.xlsx")) f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))

View File

@ -116,7 +116,7 @@ func (ws *xlsxWorksheet) setSheetProps(opts *SheetPropsOptions) {
prepareTabColor := func(ws *xlsxWorksheet) { prepareTabColor := func(ws *xlsxWorksheet) {
ws.prepareSheetPr() ws.prepareSheetPr()
if ws.SheetPr.TabColor == nil { if ws.SheetPr.TabColor == nil {
ws.SheetPr.TabColor = new(xlsxTabColor) ws.SheetPr.TabColor = new(xlsxColor)
} }
} }
if opts.CodeName != nil { if opts.CodeName != nil {
@ -145,7 +145,12 @@ func (ws *xlsxWorksheet) setSheetProps(opts *SheetPropsOptions) {
if !s.Field(i).IsNil() { if !s.Field(i).IsNil() {
prepareTabColor(ws) prepareTabColor(ws)
name := s.Type().Field(i).Name name := s.Type().Field(i).Name
reflect.ValueOf(ws.SheetPr.TabColor).Elem().FieldByName(name[8:]).Set(s.Field(i).Elem()) fld := reflect.ValueOf(ws.SheetPr.TabColor).Elem().FieldByName(name[8:])
if s.Field(i).Kind() == reflect.Ptr && fld.Kind() == reflect.Ptr {
fld.Set(s.Field(i))
continue
}
fld.Set(s.Field(i).Elem())
} }
} }
} }
@ -206,7 +211,7 @@ func (f *File) GetSheetProps(sheet string) (SheetPropsOptions, error) {
if ws.SheetPr.TabColor != nil { if ws.SheetPr.TabColor != nil {
opts.TabColorIndexed = intPtr(ws.SheetPr.TabColor.Indexed) opts.TabColorIndexed = intPtr(ws.SheetPr.TabColor.Indexed)
opts.TabColorRGB = stringPtr(ws.SheetPr.TabColor.RGB) opts.TabColorRGB = stringPtr(ws.SheetPr.TabColor.RGB)
opts.TabColorTheme = intPtr(ws.SheetPr.TabColor.Theme) opts.TabColorTheme = ws.SheetPr.TabColor.Theme
opts.TabColorTint = float64Ptr(ws.SheetPr.TabColor.Tint) opts.TabColorTint = float64Ptr(ws.SheetPr.TabColor.Tint)
} }
} }

View File

@ -23,337 +23,337 @@ import (
func (f *File) addSparklineGroupByStyle(ID int) *xlsxX14SparklineGroup { func (f *File) addSparklineGroupByStyle(ID int) *xlsxX14SparklineGroup {
groups := []*xlsxX14SparklineGroup{ groups := []*xlsxX14SparklineGroup{
{ {
ColorSeries: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 5}, ColorNegative: &xlsxColor{Theme: intPtr(5)},
ColorMarkers: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(4), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(4), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 4}, ColorHigh: &xlsxColor{Theme: intPtr(4)},
ColorLow: &xlsxTabColor{Theme: 4}, ColorLow: &xlsxColor{Theme: intPtr(4)},
}, // 0 }, // 0
{ {
ColorSeries: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 5}, ColorNegative: &xlsxColor{Theme: intPtr(5)},
ColorMarkers: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(4), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(4), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 4}, ColorHigh: &xlsxColor{Theme: intPtr(4)},
ColorLow: &xlsxTabColor{Theme: 4}, ColorLow: &xlsxColor{Theme: intPtr(4)},
}, // 1 }, // 1
{ {
ColorSeries: &xlsxTabColor{Theme: 5, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(5), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 6}, ColorNegative: &xlsxColor{Theme: intPtr(6)},
ColorMarkers: &xlsxTabColor{Theme: 5, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(5), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(5), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(5), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 5}, ColorHigh: &xlsxColor{Theme: intPtr(5)},
ColorLow: &xlsxTabColor{Theme: 5}, ColorLow: &xlsxColor{Theme: intPtr(5)},
}, // 2 }, // 2
{ {
ColorSeries: &xlsxTabColor{Theme: 6, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(6), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 7}, ColorNegative: &xlsxColor{Theme: intPtr(7)},
ColorMarkers: &xlsxTabColor{Theme: 6, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(6), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(6), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(6), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 6}, ColorHigh: &xlsxColor{Theme: intPtr(6)},
ColorLow: &xlsxTabColor{Theme: 6}, ColorLow: &xlsxColor{Theme: intPtr(6)},
}, // 3 }, // 3
{ {
ColorSeries: &xlsxTabColor{Theme: 7, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(7), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 8}, ColorNegative: &xlsxColor{Theme: intPtr(8)},
ColorMarkers: &xlsxTabColor{Theme: 7, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(7), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(7), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(7), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 7}, ColorHigh: &xlsxColor{Theme: intPtr(7)},
ColorLow: &xlsxTabColor{Theme: 7}, ColorLow: &xlsxColor{Theme: intPtr(7)},
}, // 4 }, // 4
{ {
ColorSeries: &xlsxTabColor{Theme: 8, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(8), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 9}, ColorNegative: &xlsxColor{Theme: intPtr(9)},
ColorMarkers: &xlsxTabColor{Theme: 8, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(8), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(8), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(8), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 8}, ColorHigh: &xlsxColor{Theme: intPtr(8)},
ColorLow: &xlsxTabColor{Theme: 8}, ColorLow: &xlsxColor{Theme: intPtr(8)},
}, // 5 }, // 5
{ {
ColorSeries: &xlsxTabColor{Theme: 9, Tint: -0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(9), Tint: -0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 4}, ColorNegative: &xlsxColor{Theme: intPtr(4)},
ColorMarkers: &xlsxTabColor{Theme: 9, Tint: -0.499984740745262}, ColorMarkers: &xlsxColor{Theme: intPtr(9), Tint: -0.499984740745262},
ColorFirst: &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921}, ColorFirst: &xlsxColor{Theme: intPtr(9), Tint: 0.39997558519241921},
ColorLast: &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921}, ColorLast: &xlsxColor{Theme: intPtr(9), Tint: 0.39997558519241921},
ColorHigh: &xlsxTabColor{Theme: 9}, ColorHigh: &xlsxColor{Theme: intPtr(9)},
ColorLow: &xlsxTabColor{Theme: 9}, ColorLow: &xlsxColor{Theme: intPtr(9)},
}, // 6 }, // 6
{ {
ColorSeries: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 5}, ColorNegative: &xlsxColor{Theme: intPtr(5)},
ColorMarkers: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 5}, ColorHigh: &xlsxColor{Theme: intPtr(5)},
ColorLow: &xlsxTabColor{Theme: 5}, ColorLow: &xlsxColor{Theme: intPtr(5)},
}, // 7 }, // 7
{ {
ColorSeries: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 6}, ColorNegative: &xlsxColor{Theme: intPtr(6)},
ColorMarkers: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
}, // 8 }, // 8
{ {
ColorSeries: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 7}, ColorNegative: &xlsxColor{Theme: intPtr(7)},
ColorMarkers: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
}, // 9 }, // 9
{ {
ColorSeries: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 8}, ColorNegative: &xlsxColor{Theme: intPtr(8)},
ColorMarkers: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
}, // 10 }, // 10
{ {
ColorSeries: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 9}, ColorNegative: &xlsxColor{Theme: intPtr(9)},
ColorMarkers: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
}, // 11 }, // 11
{ {
ColorSeries: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorSeries: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorNegative: &xlsxTabColor{Theme: 4}, ColorNegative: &xlsxColor{Theme: intPtr(4)},
ColorMarkers: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
}, // 12 }, // 12
{ {
ColorSeries: &xlsxTabColor{Theme: 4}, ColorSeries: &xlsxColor{Theme: intPtr(4)},
ColorNegative: &xlsxTabColor{Theme: 5}, ColorNegative: &xlsxColor{Theme: intPtr(5)},
ColorMarkers: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
}, // 13 }, // 13
{ {
ColorSeries: &xlsxTabColor{Theme: 5}, ColorSeries: &xlsxColor{Theme: intPtr(5)},
ColorNegative: &xlsxTabColor{Theme: 6}, ColorNegative: &xlsxColor{Theme: intPtr(6)},
ColorMarkers: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
}, // 14 }, // 14
{ {
ColorSeries: &xlsxTabColor{Theme: 6}, ColorSeries: &xlsxColor{Theme: intPtr(6)},
ColorNegative: &xlsxTabColor{Theme: 7}, ColorNegative: &xlsxColor{Theme: intPtr(7)},
ColorMarkers: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
}, // 15 }, // 15
{ {
ColorSeries: &xlsxTabColor{Theme: 7}, ColorSeries: &xlsxColor{Theme: intPtr(7)},
ColorNegative: &xlsxTabColor{Theme: 8}, ColorNegative: &xlsxColor{Theme: intPtr(8)},
ColorMarkers: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
}, // 16 }, // 16
{ {
ColorSeries: &xlsxTabColor{Theme: 8}, ColorSeries: &xlsxColor{Theme: intPtr(8)},
ColorNegative: &xlsxTabColor{Theme: 9}, ColorNegative: &xlsxColor{Theme: intPtr(9)},
ColorMarkers: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
}, // 17 }, // 17
{ {
ColorSeries: &xlsxTabColor{Theme: 9}, ColorSeries: &xlsxColor{Theme: intPtr(9)},
ColorNegative: &xlsxTabColor{Theme: 4}, ColorNegative: &xlsxColor{Theme: intPtr(4)},
ColorMarkers: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
}, // 18 }, // 18
{ {
ColorSeries: &xlsxTabColor{Theme: 4, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(4), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 4, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(4), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 4, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(4), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 4, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(4), Tint: -0.499984740745262},
}, // 19 }, // 19
{ {
ColorSeries: &xlsxTabColor{Theme: 5, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(5), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 5, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(5), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 5, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(5), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 5, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(5), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 5, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(5), Tint: -0.499984740745262},
}, // 20 }, // 20
{ {
ColorSeries: &xlsxTabColor{Theme: 6, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(6), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 6, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(6), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 6, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(6), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 6, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(6), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 6, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(6), Tint: -0.499984740745262},
}, // 21 }, // 21
{ {
ColorSeries: &xlsxTabColor{Theme: 7, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(7), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 7, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(7), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 7, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(7), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 7, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(7), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 7, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(7), Tint: -0.499984740745262},
}, // 22 }, // 22
{ {
ColorSeries: &xlsxTabColor{Theme: 8, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(8), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 8, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(8), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 8, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(8), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 8, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(8), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 8, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(8), Tint: -0.499984740745262},
}, // 23 }, // 23
{ {
ColorSeries: &xlsxTabColor{Theme: 9, Tint: 0.39997558519241921}, ColorSeries: &xlsxColor{Theme: intPtr(9), Tint: 0.39997558519241921},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: -0.499984740745262}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: -0.499984740745262},
ColorMarkers: &xlsxTabColor{Theme: 9, Tint: 0.79998168889431442}, ColorMarkers: &xlsxColor{Theme: intPtr(9), Tint: 0.79998168889431442},
ColorFirst: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 9, Tint: -0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(9), Tint: -0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 9, Tint: -0.499984740745262}, ColorHigh: &xlsxColor{Theme: intPtr(9), Tint: -0.499984740745262},
ColorLow: &xlsxTabColor{Theme: 9, Tint: -0.499984740745262}, ColorLow: &xlsxColor{Theme: intPtr(9), Tint: -0.499984740745262},
}, // 24 }, // 24
{ {
ColorSeries: &xlsxTabColor{Theme: 1, Tint: 0.499984740745262}, ColorSeries: &xlsxColor{Theme: intPtr(1), Tint: 0.499984740745262},
ColorNegative: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorNegative: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
ColorMarkers: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 1, Tint: 0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(1), Tint: 0.249977111117893},
}, // 25 }, // 25
{ {
ColorSeries: &xlsxTabColor{Theme: 1, Tint: 0.34998626667073579}, ColorSeries: &xlsxColor{Theme: intPtr(1), Tint: 0.34998626667073579},
ColorNegative: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorNegative: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
ColorMarkers: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorMarkers: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
ColorFirst: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorFirst: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
ColorLast: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorLast: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
ColorHigh: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorHigh: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
ColorLow: &xlsxTabColor{Theme: 0, Tint: 0.249977111117893}, ColorLow: &xlsxColor{Theme: intPtr(0), Tint: 0.249977111117893},
}, // 26 }, // 26
{ {
ColorSeries: &xlsxTabColor{RGB: "FF323232"}, ColorSeries: &xlsxColor{RGB: "FF323232"},
ColorNegative: &xlsxTabColor{RGB: "FFD00000"}, ColorNegative: &xlsxColor{RGB: "FFD00000"},
ColorMarkers: &xlsxTabColor{RGB: "FFD00000"}, ColorMarkers: &xlsxColor{RGB: "FFD00000"},
ColorFirst: &xlsxTabColor{RGB: "FFD00000"}, ColorFirst: &xlsxColor{RGB: "FFD00000"},
ColorLast: &xlsxTabColor{RGB: "FFD00000"}, ColorLast: &xlsxColor{RGB: "FFD00000"},
ColorHigh: &xlsxTabColor{RGB: "FFD00000"}, ColorHigh: &xlsxColor{RGB: "FFD00000"},
ColorLow: &xlsxTabColor{RGB: "FFD00000"}, ColorLow: &xlsxColor{RGB: "FFD00000"},
}, // 27 }, // 27
{ {
ColorSeries: &xlsxTabColor{RGB: "FF000000"}, ColorSeries: &xlsxColor{RGB: "FF000000"},
ColorNegative: &xlsxTabColor{RGB: "FF0070C0"}, ColorNegative: &xlsxColor{RGB: "FF0070C0"},
ColorMarkers: &xlsxTabColor{RGB: "FF0070C0"}, ColorMarkers: &xlsxColor{RGB: "FF0070C0"},
ColorFirst: &xlsxTabColor{RGB: "FF0070C0"}, ColorFirst: &xlsxColor{RGB: "FF0070C0"},
ColorLast: &xlsxTabColor{RGB: "FF0070C0"}, ColorLast: &xlsxColor{RGB: "FF0070C0"},
ColorHigh: &xlsxTabColor{RGB: "FF0070C0"}, ColorHigh: &xlsxColor{RGB: "FF0070C0"},
ColorLow: &xlsxTabColor{RGB: "FF0070C0"}, ColorLow: &xlsxColor{RGB: "FF0070C0"},
}, // 28 }, // 28
{ {
ColorSeries: &xlsxTabColor{RGB: "FF376092"}, ColorSeries: &xlsxColor{RGB: "FF376092"},
ColorNegative: &xlsxTabColor{RGB: "FFD00000"}, ColorNegative: &xlsxColor{RGB: "FFD00000"},
ColorMarkers: &xlsxTabColor{RGB: "FFD00000"}, ColorMarkers: &xlsxColor{RGB: "FFD00000"},
ColorFirst: &xlsxTabColor{RGB: "FFD00000"}, ColorFirst: &xlsxColor{RGB: "FFD00000"},
ColorLast: &xlsxTabColor{RGB: "FFD00000"}, ColorLast: &xlsxColor{RGB: "FFD00000"},
ColorHigh: &xlsxTabColor{RGB: "FFD00000"}, ColorHigh: &xlsxColor{RGB: "FFD00000"},
ColorLow: &xlsxTabColor{RGB: "FFD00000"}, ColorLow: &xlsxColor{RGB: "FFD00000"},
}, // 29 }, // 29
{ {
ColorSeries: &xlsxTabColor{RGB: "FF0070C0"}, ColorSeries: &xlsxColor{RGB: "FF0070C0"},
ColorNegative: &xlsxTabColor{RGB: "FF000000"}, ColorNegative: &xlsxColor{RGB: "FF000000"},
ColorMarkers: &xlsxTabColor{RGB: "FF000000"}, ColorMarkers: &xlsxColor{RGB: "FF000000"},
ColorFirst: &xlsxTabColor{RGB: "FF000000"}, ColorFirst: &xlsxColor{RGB: "FF000000"},
ColorLast: &xlsxTabColor{RGB: "FF000000"}, ColorLast: &xlsxColor{RGB: "FF000000"},
ColorHigh: &xlsxTabColor{RGB: "FF000000"}, ColorHigh: &xlsxColor{RGB: "FF000000"},
ColorLow: &xlsxTabColor{RGB: "FF000000"}, ColorLow: &xlsxColor{RGB: "FF000000"},
}, // 30 }, // 30
{ {
ColorSeries: &xlsxTabColor{RGB: "FF5F5F5F"}, ColorSeries: &xlsxColor{RGB: "FF5F5F5F"},
ColorNegative: &xlsxTabColor{RGB: "FFFFB620"}, ColorNegative: &xlsxColor{RGB: "FFFFB620"},
ColorMarkers: &xlsxTabColor{RGB: "FFD70077"}, ColorMarkers: &xlsxColor{RGB: "FFD70077"},
ColorFirst: &xlsxTabColor{RGB: "FF5687C2"}, ColorFirst: &xlsxColor{RGB: "FF5687C2"},
ColorLast: &xlsxTabColor{RGB: "FF359CEB"}, ColorLast: &xlsxColor{RGB: "FF359CEB"},
ColorHigh: &xlsxTabColor{RGB: "FF56BE79"}, ColorHigh: &xlsxColor{RGB: "FF56BE79"},
ColorLow: &xlsxTabColor{RGB: "FFFF5055"}, ColorLow: &xlsxColor{RGB: "FFFF5055"},
}, // 31 }, // 31
{ {
ColorSeries: &xlsxTabColor{RGB: "FF5687C2"}, ColorSeries: &xlsxColor{RGB: "FF5687C2"},
ColorNegative: &xlsxTabColor{RGB: "FFFFB620"}, ColorNegative: &xlsxColor{RGB: "FFFFB620"},
ColorMarkers: &xlsxTabColor{RGB: "FFD70077"}, ColorMarkers: &xlsxColor{RGB: "FFD70077"},
ColorFirst: &xlsxTabColor{RGB: "FF777777"}, ColorFirst: &xlsxColor{RGB: "FF777777"},
ColorLast: &xlsxTabColor{RGB: "FF359CEB"}, ColorLast: &xlsxColor{RGB: "FF359CEB"},
ColorHigh: &xlsxTabColor{RGB: "FF56BE79"}, ColorHigh: &xlsxColor{RGB: "FF56BE79"},
ColorLow: &xlsxTabColor{RGB: "FFFF5055"}, ColorLow: &xlsxColor{RGB: "FFFF5055"},
}, // 32 }, // 32
{ {
ColorSeries: &xlsxTabColor{RGB: "FFC6EFCE"}, ColorSeries: &xlsxColor{RGB: "FFC6EFCE"},
ColorNegative: &xlsxTabColor{RGB: "FFFFC7CE"}, ColorNegative: &xlsxColor{RGB: "FFFFC7CE"},
ColorMarkers: &xlsxTabColor{RGB: "FF8CADD6"}, ColorMarkers: &xlsxColor{RGB: "FF8CADD6"},
ColorFirst: &xlsxTabColor{RGB: "FFFFDC47"}, ColorFirst: &xlsxColor{RGB: "FFFFDC47"},
ColorLast: &xlsxTabColor{RGB: "FFFFEB9C"}, ColorLast: &xlsxColor{RGB: "FFFFEB9C"},
ColorHigh: &xlsxTabColor{RGB: "FF60D276"}, ColorHigh: &xlsxColor{RGB: "FF60D276"},
ColorLow: &xlsxTabColor{RGB: "FFFF5367"}, ColorLow: &xlsxColor{RGB: "FFFF5367"},
}, // 33 }, // 33
{ {
ColorSeries: &xlsxTabColor{RGB: "FF00B050"}, ColorSeries: &xlsxColor{RGB: "FF00B050"},
ColorNegative: &xlsxTabColor{RGB: "FFFF0000"}, ColorNegative: &xlsxColor{RGB: "FFFF0000"},
ColorMarkers: &xlsxTabColor{RGB: "FF0070C0"}, ColorMarkers: &xlsxColor{RGB: "FF0070C0"},
ColorFirst: &xlsxTabColor{RGB: "FFFFC000"}, ColorFirst: &xlsxColor{RGB: "FFFFC000"},
ColorLast: &xlsxTabColor{RGB: "FFFFC000"}, ColorLast: &xlsxColor{RGB: "FFFFC000"},
ColorHigh: &xlsxTabColor{RGB: "FF00B050"}, ColorHigh: &xlsxColor{RGB: "FF00B050"},
ColorLow: &xlsxTabColor{RGB: "FFFF0000"}, ColorLow: &xlsxColor{RGB: "FFFF0000"},
}, // 34 }, // 34
{ {
ColorSeries: &xlsxTabColor{Theme: 3}, ColorSeries: &xlsxColor{Theme: intPtr(3)},
ColorNegative: &xlsxTabColor{Theme: 9}, ColorNegative: &xlsxColor{Theme: intPtr(9)},
ColorMarkers: &xlsxTabColor{Theme: 8}, ColorMarkers: &xlsxColor{Theme: intPtr(8)},
ColorFirst: &xlsxTabColor{Theme: 4}, ColorFirst: &xlsxColor{Theme: intPtr(4)},
ColorLast: &xlsxTabColor{Theme: 5}, ColorLast: &xlsxColor{Theme: intPtr(5)},
ColorHigh: &xlsxTabColor{Theme: 6}, ColorHigh: &xlsxColor{Theme: intPtr(6)},
ColorLow: &xlsxTabColor{Theme: 7}, ColorLow: &xlsxColor{Theme: intPtr(7)},
}, // 35 }, // 35
{ {
ColorSeries: &xlsxTabColor{Theme: 1}, ColorSeries: &xlsxColor{Theme: intPtr(1)},
ColorNegative: &xlsxTabColor{Theme: 9}, ColorNegative: &xlsxColor{Theme: intPtr(9)},
ColorMarkers: &xlsxTabColor{Theme: 8}, ColorMarkers: &xlsxColor{Theme: intPtr(8)},
ColorFirst: &xlsxTabColor{Theme: 4}, ColorFirst: &xlsxColor{Theme: intPtr(4)},
ColorLast: &xlsxTabColor{Theme: 5}, ColorLast: &xlsxColor{Theme: intPtr(5)},
ColorHigh: &xlsxTabColor{Theme: 6}, ColorHigh: &xlsxColor{Theme: intPtr(6)},
ColorLow: &xlsxTabColor{Theme: 7}, ColorLow: &xlsxColor{Theme: intPtr(7)},
}, // 36 }, // 36
} }
return groups[ID] return groups[ID]
@ -427,7 +427,7 @@ func (f *File) AddSparkline(sheet string, opts *SparklineOptions) error {
group.DisplayXAxis = opts.Axis group.DisplayXAxis = opts.Axis
group.Markers = opts.Markers group.Markers = opts.Markers
if opts.SeriesColor != "" { if opts.SeriesColor != "" {
group.ColorSeries = &xlsxTabColor{ group.ColorSeries = &xlsxColor{
RGB: getPaletteColor(opts.SeriesColor), RGB: getPaletteColor(opts.SeriesColor),
} }
} }

View File

@ -753,7 +753,7 @@ var currencyNumFmt = map[int]string{
// builtInNumFmtFunc defined the format conversion functions map. Partial format // builtInNumFmtFunc defined the format conversion functions map. Partial format
// code doesn't support currently and will return original string. // code doesn't support currently and will return original string.
var builtInNumFmtFunc = map[int]func(v, format string, date1904 bool) string{ var builtInNumFmtFunc = map[int]func(v, format string, date1904 bool, cellType CellType) string{
0: format, 0: format,
1: formatToInt, 1: formatToInt,
2: formatToFloat, 2: formatToFloat,
@ -892,8 +892,8 @@ func printCommaSep(text string) string {
// formatToInt provides a function to convert original string to integer // formatToInt provides a function to convert original string to integer
// format as string type by given built-in number formats code and cell // format as string type by given built-in number formats code and cell
// string. // string.
func formatToInt(v, format string, date1904 bool) string { func formatToInt(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -906,8 +906,8 @@ func formatToInt(v, format string, date1904 bool) string {
// formatToFloat provides a function to convert original string to float // formatToFloat provides a function to convert original string to float
// format as string type by given built-in number formats code and cell // format as string type by given built-in number formats code and cell
// string. // string.
func formatToFloat(v, format string, date1904 bool) string { func formatToFloat(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -924,8 +924,8 @@ func formatToFloat(v, format string, date1904 bool) string {
// formatToIntSeparator provides a function to convert original string to // formatToIntSeparator provides a function to convert original string to
// integer format as string type by given built-in number formats code and cell // integer format as string type by given built-in number formats code and cell
// string. // string.
func formatToIntSeparator(v, format string, date1904 bool) string { func formatToIntSeparator(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -937,8 +937,8 @@ func formatToIntSeparator(v, format string, date1904 bool) string {
// formatToA provides a function to convert original string to special format // formatToA provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. // as string type by given built-in number formats code and cell string.
func formatToA(v, format string, date1904 bool) string { func formatToA(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -960,8 +960,8 @@ func formatToA(v, format string, date1904 bool) string {
// formatToB provides a function to convert original string to special format // formatToB provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. // as string type by given built-in number formats code and cell string.
func formatToB(v, format string, date1904 bool) string { func formatToB(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -990,8 +990,8 @@ func formatToB(v, format string, date1904 bool) string {
// formatToC provides a function to convert original string to special format // formatToC provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. // as string type by given built-in number formats code and cell string.
func formatToC(v, format string, date1904 bool) string { func formatToC(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -1007,8 +1007,8 @@ func formatToC(v, format string, date1904 bool) string {
// formatToD provides a function to convert original string to special format // formatToD provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. // as string type by given built-in number formats code and cell string.
func formatToD(v, format string, date1904 bool) string { func formatToD(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)
@ -1024,8 +1024,8 @@ func formatToD(v, format string, date1904 bool) string {
// formatToE provides a function to convert original string to special format // formatToE provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. // as string type by given built-in number formats code and cell string.
func formatToE(v, format string, date1904 bool) string { func formatToE(v, format string, date1904 bool, cellType CellType) string {
if strings.Contains(v, "_") { if strings.Contains(v, "_") || cellType == CellTypeSharedString || cellType == CellTypeInlineString {
return v return v
} }
f, err := strconv.ParseFloat(v, 64) f, err := strconv.ParseFloat(v, 64)

View File

@ -35,10 +35,10 @@ type xlsxChartsheet struct {
// xlsxChartsheetPr specifies chart sheet properties. // xlsxChartsheetPr specifies chart sheet properties.
type xlsxChartsheetPr struct { type xlsxChartsheetPr struct {
XMLName xml.Name `xml:"sheetPr"` XMLName xml.Name `xml:"sheetPr"`
PublishedAttr bool `xml:"published,attr,omitempty"` PublishedAttr bool `xml:"published,attr,omitempty"`
CodeNameAttr string `xml:"codeName,attr,omitempty"` CodeNameAttr string `xml:"codeName,attr,omitempty"`
TabColor *xlsxTabColor `xml:"tabColor"` TabColor *xlsxColor `xml:"tabColor"`
} }
// xlsxChartsheetViews specifies chart sheet views. // xlsxChartsheetViews specifies chart sheet views.

View File

@ -241,7 +241,7 @@ type xlsxSheetPr struct {
CodeName string `xml:"codeName,attr,omitempty"` CodeName string `xml:"codeName,attr,omitempty"`
FilterMode bool `xml:"filterMode,attr,omitempty"` FilterMode bool `xml:"filterMode,attr,omitempty"`
EnableFormatConditionsCalculation *bool `xml:"enableFormatConditionsCalculation,attr"` EnableFormatConditionsCalculation *bool `xml:"enableFormatConditionsCalculation,attr"`
TabColor *xlsxTabColor `xml:"tabColor"` TabColor *xlsxColor `xml:"tabColor"`
OutlinePr *xlsxOutlinePr `xml:"outlinePr"` OutlinePr *xlsxOutlinePr `xml:"outlinePr"`
PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr"` PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr"`
} }
@ -261,15 +261,6 @@ type xlsxPageSetUpPr struct {
FitToPage bool `xml:"fitToPage,attr,omitempty"` FitToPage bool `xml:"fitToPage,attr,omitempty"`
} }
// xlsxTabColor represents background color of the sheet tab.
type xlsxTabColor struct {
Auto bool `xml:"auto,attr,omitempty"`
Indexed int `xml:"indexed,attr,omitempty"`
RGB string `xml:"rgb,attr,omitempty"`
Theme int `xml:"theme,attr,omitempty"`
Tint float64 `xml:"tint,attr,omitempty"`
}
// xlsxCols defines column width and column formatting for one or more columns // xlsxCols defines column width and column formatting for one or more columns
// of the worksheet. // of the worksheet.
type xlsxCols struct { type xlsxCols struct {
@ -850,14 +841,14 @@ type xlsxX14SparklineGroup struct {
MinAxisType string `xml:"minAxisType,attr,omitempty"` MinAxisType string `xml:"minAxisType,attr,omitempty"`
MaxAxisType string `xml:"maxAxisType,attr,omitempty"` MaxAxisType string `xml:"maxAxisType,attr,omitempty"`
RightToLeft bool `xml:"rightToLeft,attr,omitempty"` RightToLeft bool `xml:"rightToLeft,attr,omitempty"`
ColorSeries *xlsxTabColor `xml:"x14:colorSeries"` ColorSeries *xlsxColor `xml:"x14:colorSeries"`
ColorNegative *xlsxTabColor `xml:"x14:colorNegative"` ColorNegative *xlsxColor `xml:"x14:colorNegative"`
ColorAxis *xlsxColor `xml:"x14:colorAxis"` ColorAxis *xlsxColor `xml:"x14:colorAxis"`
ColorMarkers *xlsxTabColor `xml:"x14:colorMarkers"` ColorMarkers *xlsxColor `xml:"x14:colorMarkers"`
ColorFirst *xlsxTabColor `xml:"x14:colorFirst"` ColorFirst *xlsxColor `xml:"x14:colorFirst"`
ColorLast *xlsxTabColor `xml:"x14:colorLast"` ColorLast *xlsxColor `xml:"x14:colorLast"`
ColorHigh *xlsxTabColor `xml:"x14:colorHigh"` ColorHigh *xlsxColor `xml:"x14:colorHigh"`
ColorLow *xlsxTabColor `xml:"x14:colorLow"` ColorLow *xlsxColor `xml:"x14:colorLow"`
Sparklines xlsxX14Sparklines `xml:"x14:sparklines"` Sparklines xlsxX14Sparklines `xml:"x14:sparklines"`
} }