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

Applying number format to columns #234

Open
gyansinha opened this issue Aug 4, 2023 · 1 comment
Open

Applying number format to columns #234

gyansinha opened this issue Aug 4, 2023 · 1 comment

Comments

@gyansinha
Copy link

I know how to create number formats as in:

    currencyfmt = XLSX.styles_add_numFmt(wb, "\$#,0.00;(\$#,0.00)")
    currencystyle = XLSX.styles_add_cell_xf(
        wb, Dict("applyNumberFormat" => "2", "numFmtId" => "$currencyfmt")
    )

After using something like

XLSX.writetable!(sheet, df)

how would I apply the currencystyle to say column B in the sheet that now contains the dataframe df?

@grahamgill
Copy link

grahamgill commented May 13, 2024

Some months have passed, so I hope this still can help. I came across your comment while looking for answers to how to apply styles to cells using XLSX.jl.

The answer I came up with is just to apply XLSX.CellValue(value, style) to each element of a matrix, DataFrame column, etc., in Julia, before writing out to Excel using the methods of XLSX.jl. Maybe not the most elegant or efficient, but it worked for what I needed.

Example here.

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