Learn R Programming

openxlsx2 (version 0.7)

get_date_origin: Get the date origin an xlsx file is using

Description

Return the date origin used internally by an xlsx or xlsm file

Usage

get_date_origin(xlsxFile, origin = FALSE)

Value

One of "1900-01-01" or "1904-01-01".

Arguments

xlsxFile

An xlsx or xlsm file or a wbWorkbook object.

origin

return the origin instead of the character string.

Details

Excel stores dates as the number of days from either 1904-01-01 or 1900-01-01. This function checks the date origin being used in an Excel file and returns is so it can be used in convert_date()

See Also

convert_date()

Examples

Run this code

## create a file with some dates
temp <- temp_xlsx()
write_xlsx(as.Date("2015-01-10") - (0:4), file = temp)
m <- read_xlsx(temp)

## convert to dates
do <- get_date_origin(system.file("extdata", "readTest.xlsx", package = "openxlsx2"))
convert_date(m[[1]], do)

get_date_origin(wb_workbook())
get_date_origin(wb_workbook(), origin = TRUE)

Run the code above in your browser using DataLab