-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add NumFmtIdToCodeHook support user defined numFmtId to code ma…
…pping
- Loading branch information
Showing
5 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package excelize | ||
|
||
import "encoding/xml" | ||
|
||
type NumFmtIdToCodeHookInfo struct { | ||
XmlAttr map[string][]xml.Attr | ||
NumFmt []*xlsxNumFmt | ||
} | ||
|
||
// NumFmtIdToCodeHook User-defined mapping function for numFmtId to numFmtCode | ||
// if return ok is false, will use default mapping | ||
type NumFmtIdToCodeHook func(info NumFmtIdToCodeHookInfo, numFmtId int) (numFmtCode string, ok bool) | ||
|
||
func runNumFmtIdToCodeHook(file *File, numFmtId int) (numFmtCode string, ok bool) { | ||
if file == nil || file.options == nil || file.options.NumFmtIdToCodeHook == nil { | ||
return | ||
} | ||
hookInfo := NumFmtIdToCodeHookInfo{XmlAttr: file.xmlAttr} | ||
if file.Styles != nil && file.Styles.NumFmts != nil { | ||
hookInfo.NumFmt = file.Styles.NumFmts.NumFmt | ||
} | ||
return file.options.NumFmtIdToCodeHook(NumFmtIdToCodeHookInfo{XmlAttr: file.xmlAttr}, numFmtId) | ||
} |
Binary file not shown.