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

Write number as character without Excel error #503

Closed
JanMarvin opened this issue Dec 28, 2022 · 0 comments
Closed

Write number as character without Excel error #503

JanMarvin opened this issue Dec 28, 2022 · 0 comments

Comments

@JanMarvin
Copy link
Owner

In the example below we write 1992 three times: (i) as character, (ii) as numeric with a style format and (iii) as numeric. This is the output from Excel:

Screenshot 2022-12-28 at 18 44 47

The first cell contains a number written as character, therefore the well known Excel green flag error. The second is the Excel way of writing a number as character. This uses a special style designed for this. Finally, the third is simply a number.

We might want to look into ways to write the correct way per default. Tough currently I am not sure how to approach this efficiently.

library(openxlsx2)


wb <- wb_workbook()$add_worksheet()$
  add_data(dims = "A1", x = "1992")$
  add_data(dims = "A2", x = 1992)$
  add_data(dims = "A3", x = 1992)

wb$add_cell_style(dims = "A2", applyNumberFormat = "1", quotePrefix = "1", numFmtId = "49")

# wb$open()
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

1 participant