I've noticed recently when I create excel workbooks using the openxlsx package that it produces a spreadsheet with a default column width of 10.71 rather than the usual 8.43 that we would normally get in excel. For example, if I run the following code to create a totally blank excel spreadsheet, all columns come out at 10.71 width.
wb <- openxlsx::createWorkbook()
openxlsx::addWorksheet(wb, "Sheet 1")
openxlsx::saveWorkbook(wb, "Test File.xlsx", overwrite = TRUE)
Does anyone know how to set the default column width back to the standard 8.43? I know that I can run the following to change the column widths, but this is adds additional formatting onto the spreadsheet, which will increase my file size once I've pulled in a larger dataset. It also means that the columns from my dataframe that has been exported to excel will be a different width to the columns off to the right hand side of the data (it seems trivial, but I'd like to keep things neat if possible).
openxlsx::setColWidths(wb, "Sheet 1", cols = 1:ncol(df), widths = "8.43")
There doesn't appear to be anything inside openxlsx::op.openxlsx that describes column widths, which seems a bit odd to me.
Apologies if this is a dumb question, or if I'm missing something simple, but I haven't been able to find anything about this online.