Skip to content
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

How to format numbers to Accounting format? #189

Closed
zhangcuiZC opened this issue Mar 1, 2018 · 2 comments
Closed

How to format numbers to Accounting format? #189

zhangcuiZC opened this issue Mar 1, 2018 · 2 comments

Comments

@zhangcuiZC
Copy link

From issue #80 ,I know how to format numbers to currency , but how do I format them to Accounting format? Thanks!
image
(pic from #80)

@xuri
Copy link
Member

xuri commented Mar 1, 2018

Thanks for your issue. This library not support set Accounting number format currently. I will consider to add this feature later and also welcome to contribute to this project.

@xuri
Copy link
Member

xuri commented Apr 26, 2022

Sorry for my so late reply. Excelize support set custom Accounting number format since 4a7495, for example:

f := excelize.NewFile()
if err := f.SetCellValue("Sheet1", "A1", 100); err != nil {
    fmt.Println(err)
    return
}
fmtCode := `_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)`
styleID, err := f.NewStyle(&excelize.Style{CustomNumFmt: &fmtCode})
if err != nil {
    fmt.Println(err)
    return
}
if err := f.SetCellStyle("Sheet1", "A1", "A1", styleID); err != nil {
    fmt.Println(err)
    return
}
// Save spreadsheet by the given path.
if err := f.SaveAs("Book1.xlsx"); err != nil {
    fmt.Println(err)
}

I'll close this issue, if you have any questions, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants