How to Open an .Xlsb File in R

How to open an .xlsb file in R?

Use the RODBC package:

library(RODBC)
wb <- "D:\\Data\\Masked Data.xlsb" # Give the file name
con2 <- odbcConnectExcel2007(wb)
data <- sqlFetch(con2, "Sheet1$") # Provide name of sheet
nrow(data)

How to read xlsb files?

Have a look at the excel.linkpackage here. It allows you to write / read data easily like so :

df<-xl[a1:b2] # if the file is open

or

df<-xl.read.file('filename.xlsb',header=TRUE, top.left.cell="A1") # if the file isn't open

Import Folder of xlsb files into R

Based on reading the xlsx package guide, I would think the package isn't compatible for xlsb formats. xlsb stores in binary format, whereas other excel formats are in XML. xls is an Excel 95 binary format, but apparently xlsb isn't compatible with Excel versions 2003 and prior.

Your best bet might be to try RODBC, or to save your workbook as a .csv and import from there.



Related Topics



Leave a reply



Submit