r Remove xlsx sheet using officer package - r

I am developing an R shiny app that will generate a sequence of editable charts in an Excel file using the officer package. However, when creating a new .xlsx file using the read_xlsx() function, the file contains a blank first sheet entitled "Feuil1" (apparently the template is in French).
WkBook <- read_xlsx()
WkBook
xlsx document with 1 sheet(s):
[1] "Feuil1"
After adding other appropriately named worksheets to the destination .xlsx file, is it possible to program the app to delete this extraneous "Feuil1" sheet? Officer has an add_sheet() function but doesn't appear to have a function to remove or rename a sheet.
add_sheet(WkBook, "newChart")
xlsx document with 2 sheet(s):
[1] "Feuil1" "newChart"

Related

How to check if excel file with multiple sheets contains macros/formulas in R after importing?

Once I have imported excel file with multiple sheets into R I want to check if excel sheets contains any formulas/VBA/macros into it.
Also I am not sure whether while importing any excel sheets that contains formulas also gets imported along with file in R or it's only importing values because I am not able find it.
Any help would be appreciated!!!

Is there a R function to add data from a df and append it to a sheet in excel

I have a R code that uses joins from various tables and finally have an output dataframe. I need this to be appended to a new worksheet in excel file that already has three sheets in it. I am on a mac and however I try the library(rjava) that is required for library(xlsx) wont load. Is there any other library (that doesnt need java) that I can use for this?
Edit to add: the existing excel sheet has graphs and charts in it

R - Extracting worksheet style and copying into a different workbook

I would like to copy the entire sheet (retaining the style) from one workbook into another workbook.
I tried cloneSheet() from the XLConnect package but I'm not sure if it can be used to clone a worksheet to a different workbook.
I also tried createSheet() to create a new sheet in workbook_1.xlsx then, readWorksheet() in workbook_2.xlsx, and finally writeWorksheet() to write the data from workbook_2 to workbook_1, but only the data gets transferred and not the style.
Thanks in advance for any inputs.

Is there an R function for extracting sheets names from the all the excel files in my working directory

I have around 300 excel files(with multiple sheets) in my working directory. I use the following code to extract the only the list of files from working directory.
Filesnames <- list.files()
But I also need sheet names from these excel files and I need to know from which excel files these sheets are from. For example, Excel 1 has A,B,C sheet names and Excel 2 has X,Y sheet names. When I run a code, I need to get A,B,C from Excel 1 and X,Y from Excel 2.

How to convert doc to docx file using R code

I tried to read doc file using readdoc() but when doc file consist of tables, it will not able read it properly.
Therefore I want to convert doc file to docx file so that I can extract tables using docxtractr package availabe in R.
I want to convert .doc file to .docx file using R code.

Resources