Questions tagged [r-xlsx]

The xlsx library in R has capabilities for reading and writing Microsoft Excel files

From CRAN:

Provide R functions to read/write/format Excel 2007 and Excel 97/2000/XP/2003 file formats.

xlsx uses Java (through rJava) on the back end to read and write .xls and .xlsx files.

Package written and maintained by Adrian Dragulescu.

126 questions
1
vote
2 answers

Loop to create multiple sheets in multiple Excel workbooks

I have a dataset with two different groups and their values, something like this: example <- data.frame('Group' = c('building 1', 'building 1', 'building 2', 'building 2'), 'Subgroup' =…
enl
  • 13
  • 4
1
vote
1 answer

read.xlsx2 | Skipping if sheetName does not exist

I am trying to read multiple excel files in a folder using the read.xlsx2 function. I only need to read a particular sheet titled 'Returns' or 'Prices'. Is there a way I can give an 'OR' argument in the function and also skip a file if it contains…
FinRC
  • 133
  • 8
1
vote
0 answers

cannot install rJava on macOS Catalina 10.15.1

My mac system is macOS Catalina 10.15.1, and my R version is 3.6.1. When I try to install the rJava package on Rstudio using install.packages("rJava", type="source), it comes with error: make: *** [jri_glue.o] Error 1 ERROR: compilation failed for…
1
vote
1 answer

Why does a question mark in a dataframe column title show as a period when outputting from r to an excel sheet (using xlsx package)?

Suppose I use the xlsx package to write a dataframe from r to excel. And suppose I have a dataframe with a column title that includes a question mark (code below): library(xlsx) rm(list = ls()) fpath <- "whatever filepath" #My df df <-…
Nana
  • 13
  • 2
1
vote
2 answers

write to excel all non-zero-row dataframes in global environment

I have a set of empty (0-row) and non-empty (>0-row) Tibbles in my global environment and I want to select only the relevant ones, i.e. the non-empty ones and send them to a write.xlsx command. It seems like it should be fairly doable task, yet I…
Raberto
  • 55
  • 6
1
vote
0 answers

R - xlsx package - add bottom border to set of rows

I'm using the "xlsx" package in R to read, modify and write a .xlsm file. I'm having some problems with border styling to my rows and columns: I'm adding a dataframe (df) into a sheet and I'm applying some styles to the first column (colnamesStyle)…
user1987607
  • 2,057
  • 6
  • 26
  • 53
1
vote
1 answer

Exporting multiple tibbles to XLSX -- sheetName problem when using deparse(substitute())

I have 15 tibbles that I want to export to a single XLSX workbook, with the sheetName for each set to be the same as the name of the tibble object. To export a single tibble, this works just fine: library(xlsx) my_tibble1 %>% …
Kevin Troy
  • 412
  • 4
  • 13
1
vote
0 answers

how to give all borders and some colors in r while writing excel

I'm looking for examples or ideas on how I might display a data table in a. Rmd document that has grouped totals at multiple levels. So, in the example following, the date, names, qty, rate, and value have a total at the items level. Following I…
1
vote
1 answer

How do I format an entire row within xlsx based on a cell character in R

I am using R to edit an xlsx worksheet. I would like to format the worksheet with colored rows based on character values in a specific column, then save the workbook in xlsx form. I successfully loaded the workbook using xlsx in R. I can run through…
Thomas Decker
  • 11
  • 1
  • 3
1
vote
2 answers

When writing to an excel sheet, how can I add a new row each time I run the script?

I've written a script that pulls and summarizes data from 2 databases regularly. I'm using write.xlsx to write 3 data frames to 3 different tabs: Tab1 is data from one database, Tab2 is data from another, and Tab3 is data summarized from both. It…
Brad S
  • 11
  • 1
  • 4
1
vote
0 answers

Conditionally Formatting cells in other columns based on text value of another cell

Using Xlsx Package in R, is there a way to highlight excel cells based on specific text of another cell? i.e. if C10 = "Cat" then highlight D10 and E10. I have seen many posts surrounding numeric values. I want to format based on text value and to…
C.Lee
  • 67
  • 7
1
vote
1 answer

I want to install package xlsx on R 2.8.1 on windows but I have to use .tar.gz old package when I need .zip

For reasons that are too long to explain here, I must use R.2.8.1 (unfortunately). I need to have the xlsx package installed on it. Since I am on R 2.8.1, about ten years old, I can't use the latest version of xlsx but an older version, for instance…
Matt Dnv
  • 1,620
  • 13
  • 23
1
vote
0 answers

using xlsx package to overwrite a cell reference in xlsm file

I have a .xlsm workbook that has a cell B1 that is currently referencing to Cell B2, which has a hardcoded value is 5. I'd like to use R to remove the reference from cell B1 and replace it with a hardcoded value of 0. I'm attempting to do this in…
Tyler Law
  • 73
  • 4
1
vote
0 answers

fail to install R package xlsx

Since the newest version of xlsx is still in source format I used install.packages("xlsx", type = "source") I have encountered the following issue when intalling xlsx. Error : .onLoad failed in loadNamespace() for 'rJava', details: call:…
newbie
  • 275
  • 1
  • 3
  • 15
1
vote
2 answers

Using write.xlsx inside lapply to write each data frame in Global Environment to each tab of a single Excel file

My Global Environment in R Studio consists of multiple data frames. I would like to write the data within each data frame to each tab within a single excel file. To make this question reproducible, let us consider the following data frames in the…
DTYK
  • 1,098
  • 1
  • 8
  • 33
1 2 3
8 9