-
-
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
Excel's celll format does not support numeric types #1411
Comments
Thanks for your feedback. But sorry, I don't understand what you exactly mean. This problem may be similar to issue #705, and you can use build-in number format ID 2 for the numeric data type values. You can find more built-in number format mapping details in the documentation. |
Please use the custom number format for the Kingsoft WPS, but which will incompatible with Microsoft Excel for Mac: customNumFmt := "0.00_ "
styleID, err := f.NewStyle(&excelize.Style{CustomNumFmt: &customNumFmt})
if err != nil {
fmt.Println(err)
return
} |
Which version of Excelize library and Kingsoft WPS are you using? |
exelize: 2.6.0 |
It seems your provided Kingsoft WPS version is incorrect, version 4.4.2 was released in 2001, which does not support the spreadsheet in xlsx format, I have tested with version 11.1.0.12763, and it works well. |
Thanks for your feedback. Here is an example for you reference, and it works on WPS Office for Mac: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
if err := f.SetCellValue("Sheet1", "A1", 23.455667); err != nil {
fmt.Println(err)
return
}
customNumFmt := "0.00_ "
styleID, err := f.NewStyle(&excelize.Style{CustomNumFmt: &customNumFmt})
if err != nil {
fmt.Println(err)
return
}
if err := f.SetCellStyle("Sheet1", "A1", "A1", styleID); err != nil {
fmt.Println(err)
return
}
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} |
It seems still not have enough info or feedback for this issue, so I'll close this issue, if you have any questions, please let me know to reopen this anytime. |
The question has been resolved. and the code did work! Thanks a lot!!! ❤️ |
Background
We need to use excel to display a large amount of data, including percentages, decimals, currency, time, and text.
Problem
The “decimal” cannot control the number of digits and the format is not a decimal
(the below picture shows what I want)
but most of them(I mean all the numFmt ID I test) shows "custom"
I know use "customNumFmt" can control the number of digits but the format is "custom"!
Thanks!
The text was updated successfully, but these errors were encountered: