强烈推荐:Openxlsx包——无需java环境
- 读取:Read.xlsx( ) / Read.Workbook()
> read.xlsx(xlsxFile, sheet = 1, startRow = 1, colNames = TRUE, rowNames = FALSE,
detectDates = FALSE, skipEmptyRows = TRUE, skipEmptyCols = TRUE,
rows = NULL, cols = NULL, check.names = FALSE, namedRegion = NULL, na.strings = "NA", fillMergedCells = FALSE)
- xlsxFile:. xlsx文件路径
- sheet: sheet名或者数字索引
- startRow:从哪一行开始读入,开头的空行会被跳过
- colNames、rowNames:如果TRUE,则第一行作为列/行名
- skipEmptyRows、skipEmptyCols:是否跳过空白行/列,否则该行返回NA
- rows、cows: 数值型向量,读入哪些行/列,默认为全部读入
- detecDates:当Excel表格中带日期列时需要将参数设置为TRUE,不然将会将日期识别为数字读入。
- fillMergedCells:当表格中存在合并单元格,将用值填充其他全部单元格。
write.xlsx(x, file, asTable = FALSE, firstRow = TRUE:冻结第一行,colWidths = ‘auto’:自动设置列宽)