简体   繁体   English

读取多个启用宏的Excel文件

[英]Read multiple macro-enabled Excel files

I'm trying to read approximately 500 Excel files with marcos enabled, and I'm getting this error: 我正在尝试阅读大约500个启用了marcos的Excel文件,我收到此错误:

Error: Skipped over all data 错误:跳过所有数据

This is the code I used to run the program: 这是我用来运行程序的代码:

files <- list.files(pattern = ".xlsm")
for (i in files){
  data <- ldply(files, read_excel, sheet = 'R1')
  data$file_name <- files
}

If I run the code for 10 to 15 macro-enabled files, I'm able to read the data. 如果我运行10到15个启用宏的文件的代码,我就能读取数据。 However, when trying to read in all files I get the above error. 但是,当尝试读入所有文件时,我得到上述错误。

Is there any way I can read these files? 有什么方法可以阅读这些文件吗? How can I debug this error? 我该如何调试此错误?

Does this work for you? 这对你有用吗?

library(xlsx)
setwd("C:/Users/your_path/Desktop/files")
data.files = list.files(pattern = "*.xlsm")
data <- lapply(data.files, function(x) read.xlsx(x, sheetIndex = 1))

for (i in data.files) {
    data <- rbind(data, read.xlsx(i, sheetIndex = 1))
}

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

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