###########################################################################
# numerics, dates, missings, bool and string
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx2")
wb1 <- wb_load(xlsxFile)
# import workbook
wb_to_df(wb1)
# do not convert first row to colNames
wb_to_df(wb1, colNames = FALSE)
# do not try to identify dates in the data
wb_to_df(wb1, detectDates = FALSE)
# return the underlying Excel formula instead of their values
wb_to_df(wb1, showFormula = TRUE)
# read dimension withot colNames
wb_to_df(wb1, dims = "A2:C5", colNames = FALSE)
# read selected cols
wb_to_df(wb1, cols = c(1:2, 7))
# read selected rows
wb_to_df(wb1, rows = c(1, 4, 6))
# convert characters to numerics and date (logical too?)
wb_to_df(wb1, convert = FALSE)
# erase empty Rows from dataset
wb_to_df(wb1, sheet = 3, skipEmptyRows = TRUE)
# erase rmpty Cols from dataset
wb_to_df(wb1, skipEmptyCols = TRUE)
# convert first row to rownames
wb_to_df(wb1, sheet = 3, dims = "C6:G9", rowNames = TRUE)
# define type of the data.frame
wb_to_df(wb1, cols = c(1, 4), types = c("Var1" = 0, "Var3" = 1))
# start in row 5
wb_to_df(wb1, startRow = 5, colNames = FALSE)
# na string
wb_to_df(wb1, na.strings = "")
# read_xlsx(wb1)
###########################################################################
# inlinestr
xlsxFile <- system.file("extdata", "inline_str.xlsx", package = "openxlsx2")
wb2 <- wb_load(xlsxFile)
# read dataset with inlinestr
wb_to_df(wb2)
# read_xlsx(wb2)
###########################################################################
# named_region // namedRegion
xlsxFile <- system.file("extdata", "namedRegions3.xlsx", package = "openxlsx2")
wb3 <- wb_load(xlsxFile)
# read dataset with named_region (returns global first)
wb_to_df(wb3, named_region = "MyRange", colNames = FALSE)
# read named_region from sheet
wb_to_df(wb3, named_region = "MyRange", sheet = 4, colNames = FALSE)
Run the code above in your browser using DataLab