From a410b22bdd50e9f212b0b454e5aed798e3476394 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 28 Oct 2022 00:31:55 +0800 Subject: Fix the error on getting the range of merged cells on the worksheet which contains one cell merged cell range - Parse workbook default theme for custom theme color support in the feature - Variables name typo fix - Add system foreground and background color as RGB in the IndexedColorMapping list --- styles.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'styles.go') diff --git a/styles.go b/styles.go index 15de5f1..f7d00e1 100644 --- a/styles.go +++ b/styles.go @@ -1057,6 +1057,15 @@ func (f *File) styleSheetWriter() { } } +// themeWriter provides a function to save xl/theme/theme1.xml after serialize +// structure. +func (f *File) themeWriter() { + if f.Theme != nil { + output, _ := xml.Marshal(f.Theme) + f.saveFileList(defaultXMLPathTheme, f.replaceNameSpaceBytes(defaultXMLPathTheme, output)) + } +} + // sharedStringsWriter provides a function to save xl/sharedStrings.xml after // serialize structure. func (f *File) sharedStringsWriter() { @@ -3311,11 +3320,11 @@ func getPaletteColor(color string) string { // themeReader provides a function to get the pointer to the xl/theme/theme1.xml // structure after deserialization. func (f *File) themeReader() *xlsxTheme { - var ( - err error - theme xlsxTheme - ) - if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML("xl/theme/theme1.xml")))). + if _, ok := f.Pkg.Load(defaultXMLPathTheme); !ok { + return nil + } + theme := xlsxTheme{XMLNSa: NameSpaceDrawingML.Value, XMLNSr: SourceRelationship.Value} + if err := f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(defaultXMLPathTheme)))). Decode(&theme); err != nil && err != io.EOF { log.Printf("xml decoder error: %s", err) } -- cgit v1.2.1