Home > Enterprise >  `openxlsx`: load and apply all formatting from the read file
`openxlsx`: load and apply all formatting from the read file

Time:11-24

I try to read in a spreadsheet that consists of one sheet and then add a new sheet to this file. So I read the data into R with openxlsx::read.xlsx, but in doing so I also lose the formatting of the first sheet.

Any ideas on how I can preserve the formatting of the first sheet?

CodePudding user response:

have a look at the loadWorkbook function which reads in the whole Excel file as is and then you can use addWorksheet, writeData and saveWorkbook to add a worksheet, fill it with data and save the whole thing - which should presever the formatting of your original sheets.

  • Related