wb_to_df_list() uses openxlsx2::wb_to_df() to extract each sheet of a
workbook object into a data frame. Additional parameters ... are recycled
to match the length of sheet names.
Arguments
- file
An xlsx file, wbWorkbook object or URL to xlsx file.
- sheet_names
Character vector of sheet names. If not supplied, all sheet names from the supplied workbook are used.
- ...
Arguments passed on to
openxlsx2::wb_to_dfsheetEither sheet name or index. When missing the first sheet in the workbook is selected.
start_rowfirst row to begin looking for data.
start_colfirst column to begin looking for data.
row_namesIf
TRUE, the first col of data will be used as row names.col_namesIf
TRUE, the first row of data will be used as column names.skip_empty_rowsIf
TRUE, empty rows are skipped.skip_empty_colsIf
TRUE, empty columns are skipped.skip_hidden_rowsIf
TRUE, hidden rows are skipped.skip_hidden_colsIf
TRUE, hidden columns are skipped.rowsA numeric vector specifying which rows in the xlsx file to read. If
NULL, all rows are read.colsA numeric vector specifying which columns in the xlsx file to read. If
NULL, all columns are read.detect_datesIf
TRUE, attempt to recognize dates and perform conversion.na.stringsA character vector of strings which are to be interpreted as
NA. Blank cells will be returned asNA.na.numbersA numeric vector of digits which are to be interpreted as
NA. Blank cells will be returned asNA.fill_merged_cellsIf
TRUE, the value in a merged cell is given to all cells within the merge.dimsCharacter string of type "A1:B2" as optional dimensions to be imported.
show_formulaIf
TRUE, the underlying Excel formulas are shown.convertIf
TRUE, a conversion to dates and numerics is attempted.typesA named numeric indicating, the type of the data. Names must match the returned data. See Details for more.
named_regionCharacter string with a
named_region(defined name or table). If no sheet is selected, the first appearance will be selected. Seewb_get_named_regions()keep_attributesIf
TRUEadditional attributes are returned. (These are used internally to define a cell type.)check_namesIf
TRUEthen the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names.show_hyperlinksIf
TRUEinstead of the displayed text, hyperlink targets are shown.
Examples
wb <- as_wb(list(mtcars[1:3, ], mtcars[4:6, ]))
wb_to_df_list(wb)
#> $`Sheet 1`
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> 2 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#> 3 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#> 4 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#>
#> $`Sheet 2`
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> 2 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
#> 3 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
#> 4 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
#>
wb_to_df_list(wb, "Sheet 1")
#> $`Sheet 1`
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> 2 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
#> 3 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
#> 4 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
#>