0

In R I am trying to save an Excel workbook as a binary worksheet (.xlsb) instead of the standard (.xlsx or .xls) method. Using packages like openxlsx or xlsx do not work because they do not convert the file into binary format. I have been digging and found the package excel.link but it keeps crashing my R session and doesn't seem to work in a timely manner.

Does anyone know of a method to achieve this?

2 Answers2

0

No, Excel Binary format is a proprietary encoding/compression format used by Microsoft that is not shared. You can only view and edit Binary files in excel. Is there any reason you cant save them as csvs or a regular excel file? If it is to large you can save it as a gzip file with

data.table::fwrite(file, "filename.gzip")
d3hero23
  • 380
  • 1
  • 12
0

It is possible to convert an XLSX file to XLSB with the R package RDCOMClient

library(RDCOMClient)
path_XLSX_File <- "C:\\...\\xlsx_File.xlsx"
path_XLSB_File <- "C:\\...\\xlsb_File.xlsb"

xlApp <- COMCreate("Excel.Application")
xlApp[['Visible']] <- FALSE
xlWbk <- xlApp$Workbooks()$Open(path_XLSX_File)

xlWbk$SaveAs(path_XLSB_File, 50)
xlWbk$Close()
xlApp$Quit()

For all the format, see https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2010/ff198017(v=office.14). The "XLSB" format is "xlExcel12".

Emmanuel Hamel
  • 1,769
  • 7
  • 19