From 66d0272f6af59b5f0c97a304379a795420a43e8b Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 6 Apr 2020 00:23:27 +0800 Subject: Resolve #172, init rich text support --- styles.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'styles.go') diff --git a/styles.go b/styles.go index 9cf974e..fe2bed5 100644 --- a/styles.go +++ b/styles.go @@ -13,6 +13,7 @@ import ( "bytes" "encoding/json" "encoding/xml" + "errors" "fmt" "io" "log" @@ -1022,6 +1023,15 @@ func (f *File) styleSheetWriter() { } } +// sharedStringsWriter provides a function to save xl/sharedStrings.xml after +// serialize structure. +func (f *File) sharedStringsWriter() { + if f.SharedStrings != nil { + output, _ := xml.Marshal(f.SharedStrings) + f.saveFileList("xl/sharedStrings.xml", replaceRelationshipsNameSpaceBytes(output)) + } +} + // parseFormatStyleSet provides a function to parse the format settings of the // cells and conditional formats. func parseFormatStyleSet(style string) (*Style, error) { @@ -1033,7 +1043,7 @@ func parseFormatStyleSet(style string) (*Style, error) { } // NewStyle provides a function to create the style for cells by given JSON or -// structure. Note that the color field uses RGB color code. +// structure pointer. Note that the color field uses RGB color code. // // The following shows the border styles sorted by excelize index number: // @@ -1906,6 +1916,8 @@ func (f *File) NewStyle(style interface{}) (int, error) { } case *Style: fs = v + default: + return cellXfsID, errors.New("invalid parameter type") } s := f.stylesReader() numFmtID := setNumFmt(s, fs) -- cgit v1.2.1