Skip to contents

Reports every cell whose style resolves to a date number format, together with the serial it stores and the day.month value that serial restores to. This is the audit trail behind unexcel_xlsx(): nothing here is a guess, so the output can be checked cell by cell before any value is changed.

Usage

excel_date_cells(path, sheet = 1)

Arguments

path

Path to an .xlsx file.

sheet

Sheet name, or its index in the workbook. Defaults to the first sheet.

Value

A data frame with one row per date-formatted cell and the columns ref, row, col, serial, date, num_fmt_id, format_code, field_order and day_month. The date_system attribute records the system the workbook declares. Zero rows means the workbook formats nothing as a date – there is nothing to restore.

Details

A cell is reported when its number format is one of Excel's built-in date formats, or a custom format whose code contains date tokens, and it holds a number. Text that merely looks like a date is left alone.

See also

unexcel_xlsx() to apply the restoration, excel_date_columns() to summarise this by column.

Examples

path <- system.file("extdata", "typed-numbers.xlsx", package = "unexcel")
excel_date_cells(path)
#>    ref row col serial       date num_fmt_id format_code field_order day_month
#> 1   B2   2   2  45746 2025-03-30        164    d/m/yyyy          dm     30.30
#> 2   E2   2   5  45664 2025-01-07         14    mm-dd-yy          md      1.70
#> 3   B3   3   2  45823 2025-06-15        164    d/m/yyyy          dm     15.60
#> 4   E3   3   5  45699 2025-02-11         14    mm-dd-yy          md      2.11
#> 5   B4   4   2  45933 2025-10-03        164    d/m/yyyy          dm      3.10
#> 6   E4   4   5  45720 2025-03-04         14    mm-dd-yy          md      3.40
#> 7   B5   5   2  45992 2025-12-01        164    d/m/yyyy          dm      1.12
#> 8   E5   5   5  45756 2025-04-09         14    mm-dd-yy          md      4.90
#> 9   B6   6   2  45716 2025-02-28        164    d/m/yyyy          dm     28.20
#> 10  E6   6   5  45783 2025-05-06         14    mm-dd-yy          md      5.60