Description
Dear maintainer:
When I using the following code, I found that the current CultureInfo
type only supports CultureNameZhCN
and CultureNameEnUS
, which makes it impossible for me to obtain the time and date formats of other regions through the GetCellValue
method.
package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile(excelize.Options{
CultureInfo: excelize.CultureNameZhCN, // or excelize.CultureNameEnUS
})
style1, err := f.NewStyle(&excelize.Style{
NumFmt: 27,
})
if err != nil {
fmt.Println(err)
return
}
f.SetCellStyle("Sheet1", "A2", "A2", style1)
f.SetCellValue("Sheet1", "A2", 45405)
date, err := f.GetCellValue("Sheet1", "A2")
if err != nil {
fmt.Println(err)
return
}
fmt.Println(date)
if err := f.SaveAs("./Book1.xlsx"); err != nil {
fmt.Println(err)
}
}
After checking the related documentation (ISO/IEC 29500) and source code, it is found that the source code has a complete implementation of langNumFmt
for other regions (such as zh-tw, ja-jp), but there is no corresponding function support in the getBuiltInNumFmtCode
method.
const (
CultureNameUnknown CultureName = iota
CultureNameEnUS
CultureNameZhCN
// no more methods like CultureNameZhTW
)
// ...
func (f *File) getBuiltInNumFmtCode(numFmtID int) (string, bool) {
if fmtCode, ok := builtInNumFmt[numFmtID]; ok {
return fmtCode, true
}
if isLangNumFmt(numFmtID) {
if f.options.CultureInfo == CultureNameEnUS {
return f.langNumFmtFuncEnUS(numFmtID), true
}
if f.options.CultureInfo == CultureNameZhCN {
return f.langNumFmtFuncZhCN(numFmtID), true
}
// no more methods like langNumFmtFuncZhTW
}
return "", false
}
I know that using CustomNumFmt
is also an option, but I would still like to inquire if the maintainer have plans to add support for this part, and I can do that if you are willing.
Thank you for your time and consideration.