Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting formatting information of a cell in an Excel workbook in R

Tags:

r

excel

I want to process an Excel Workbook (.xlsx or .xlsm) with multiple sheets using R. More specifically, I want to inspect the formatting (e.g. the background fill color) of each cell with data and do conditional processing based on that.

I have looked in several R packages for processing Excel files but couldn't figure out how to do this. The openxlsx package has the function getStyles which returns the list of all styles in the work book, but it is not useful for my purpose here since I want to read the style information of specific cells. The XLConnect package has similar functions which can find styles by name or data type, but the work book I want to process is prepared manually and doesn't have named styles as far as I know.

Is there a way to read style information of a single cell in an Excel Work book in R?

like image 433
Dronacharya Avatar asked Oct 15 '25 09:10

Dronacharya


1 Answers

As pointed out by Stéphane Laurent in the comment above, tidyxl package has functions to get all different styles used in a sheet, and to get cells to which each style is applied.

like image 80
Dronacharya Avatar answered Oct 17 '25 00:10

Dronacharya