-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new langNumFmtFunc in numfmt
#1895
Conversation
Signed-off-by: wushiling50 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. Could you add unit test for this changes?
No problem, it was my oversight, I'll add unit tests for these changes |
Signed-off-by: wushiling50 <[email protected]>
Signed-off-by: wushiling50 <[email protected]>
Signed-off-by: wushiling50 <[email protected]>
func main() {
f := excelize.NewFile()
numfmt1 := "e\"年\"m\"月\"d\"日\""
style1, err := f.NewStyle(&excelize.Style{
CustomNumFmt: &numfmt1,
})
if err != nil {
fmt.Println(err)
return
}
f.SetCellStyle("Sheet1", "A2", "A2", style1)
f.SetCellValue("Sheet1", "A2", 45050)
cellValue1, _ := f.GetCellValue("Sheet1", "A2")
fmt.Printf("1:%v\n", cellValue1)
numfmt2 := "yyyy\"年\"m\"月\"d\"日\""
style2, err := f.NewStyle(&excelize.Style{
CustomNumFmt: &numfmt2,
})
if err != nil {
fmt.Println(err)
return
}
f.SetCellStyle("Sheet1", "B2", "B2", style2)
f.SetCellValue("Sheet1", "B2", 45050)
cellValue2, _ := f.GetCellValue("Sheet1", "B2")
fmt.Printf("2:%v\n", cellValue2)
numfmt3 := "[$-411]ggge\"年\"m\"月\"d\"日\""
style3, err := f.NewStyle(&excelize.Style{
CustomNumFmt: &numfmt3,
})
if err != nil {
fmt.Println(err)
return
}
f.SetCellStyle("Sheet1", "C2", "C2", style3)
f.SetCellValue("Sheet1", "C2", 45050)
cellValue3, _ := f.GetCellValue("Sheet1", "C2")
fmt.Printf("3:%v\n", cellValue3)
if err := f.SaveAs("demo/Book1.xlsx"); err != nil {
fmt.Println(err)
}
}
func main() {
f := excelize.NewFile()
numfmt4 := "ว-ดดด-ปป"
style4, err := f.NewStyle(&excelize.Style{
CustomNumFmt: &numfmt4,
})
if err != nil {
fmt.Println(err)
return
}
f.SetCellStyle("Sheet1", "D2", "D2", style4)
f.SetCellValue("Sheet1", "D2", 45050)
cellValue4, _ := f.GetCellValue("Sheet1", "D2")
fmt.Printf("4:%v\n", cellValue4)
if err := f.SaveAs("demo/Book1.xlsx"); err != nil {
fmt.Println(err)
} These problems are leading to the failure of the "zh-tw" and "th-th" related tests, and if you are agreeable, I can provide the code for the "ja-jp" and "ko-kr" parts first, and within the getBuiltInNumFmtCode function, I can set a TODO comment. Both "ja-jp" part and ko-kr" part have passed the tests successfully. |
Good job. I think we need to resolve this number format code parse or evaluate the issue before merging this. Maybe it will be related to the NFP library, I'm not sure. |
79958aa
to
0c3dfb1
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1895 +/- ##
=======================================
Coverage 99.32% 99.32%
=======================================
Files 32 32
Lines 25374 25459 +85
=======================================
+ Hits 25202 25287 +85
Misses 92 92
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
- Update unit tests - Support apply number format for the Republic of China year and the Japanese calendar years
- Update unit tests - Support apply number format for the Korean Danki calendar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I have made some changes based on your branch. This feature will be released in the next version.
PR Details
Support for more built-in langNumFmt allows
GetCellValue
to fetch dates and times in more localizationsDescription
Related Issue
#1885
Motivation and Context
When I using the following code, I found that the current
CultureInfo
type only supportsCultureNameZhCN
andCultureNameEnUS
, which makes it impossible for me to obtain the time and date formats of other regions through theGetCellValue
method.How Has This Been Tested
Add Unit Test
Types of changes
Checklist