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

Export to excel with different number formats #25

Open
kp-source opened this issue Jun 29, 2020 · 2 comments
Open

Export to excel with different number formats #25

kp-source opened this issue Jun 29, 2020 · 2 comments

Comments

@kp-source
Copy link

Hi,

If I am exporting data frames to excel, can I show the currency and percentage symbols in the excel spreadsheet on certain columns ($, %)?

Cheers!

@zeehio
Copy link
Owner

zeehio commented Jun 29, 2020

I don't think I am going to provide that level of fine tuning for excel myself, since I feel it is at the limit of the scope of the package.

However, condformat uses openxlsx to export to Excel, and the following example code may be useful, if you combine it with function calls to openxlsx (please read the documentation for that package).

This is a minimal example:

library(condformat)
library(openxlsx)
data(iris)
x <- condformat(iris)
wb <- openxlsx::createWorkbook(creator = "")
addWorksheet(wb, sheetName = "sheet name")
condformat:::condformat2excelsheet(x, wb, "sheet name")
# Add here any other openxlsx function call to format the columns any way you want
saveWorkbook(wb, file = "iris.xlsx")

If this works for you, please tell me and I will document and export condformat2excelsheet in a future version, so you don't need ::: anymore.

@kp-source
Copy link
Author

Hey,

I tried and the method did work. However, I was not able to simultaneously color a cell and apply a number style like a $ sign or a percent sign to the same cell.

Cheers!

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