简体   繁体   English

如何使用 R 在 .xlsb 文件中读写? 或者我是否必须构建一个包来读/写 .xlsb 文件?

[英]how to read and write in .xlsb file using R? Or do I have to build a package to read/write .xlsb file?

I have been mainly working with .xlsb files(binary file type of xlsx) which I would like to read/write using R. Could you please let me know if there is any package that is available for this or do I need to create package on my own?我一直主要使用 .xlsb 文件(xlsx 的二进制文件类型),我想使用 R 读/写这些文件。能否请您告诉我是否有任何可用的包或我需要创建包靠我自己? RODBC did not work too. RODBC 也不起作用。

Try the excel.link package.试试excel.link包。 The xl.read.file function allows rectangular data sets to be read-in, though there are other options available. xl.read.file 函数允许读入矩形数据集,但还有其他选项可用。

You also need to (install and) call the RDCOMClient package before running the first excel.link function.在运行第一个 excel.link 函数之前,您还需要(安装和)调用 RDCOMClient 包。

eg,例如,

read_xlsb <- function(x){
  require("RDCOMClient")
  message(paste0("Reading ", x, "...\n"))
  df <- excel.link::xl.read.file(filename = x, header = TRUE, 
                                 xl.sheet = Worksheet_name)
  df$filename <- x
  df <- as.data.frame(df) 
  return(df)  
}

The only annoynce I've found is that I can't override Excel's "save on close" functionality so these pop-ups need to be closed by hand.我发现的唯一烦恼是我无法覆盖 Excel 的“关闭时保存”功能,因此需要手动关闭这些弹出窗口。

BTW I think excel.link only works on Windows machines.顺便说一句,我认为 excel.link 仅适用于 Windows 机器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM