2 Read
Functions for reading from a ".xlsx" file.
You can get a specific cell’s value or loop for the whole sheet’s rows.
There is also a complete read and write example included in the GitHub source.
procedure
(with-input-from-xlsx-file xlsx_file_path user-proc) → void? xlsx_file_path : path-string? user-proc : (-> (is-a?/c read-xlsx%) void?)
To make changes to the file, convert the read-xlsx% object to xlsx% using from-read-to-write-xlsx.
procedure
(load-sheet sheet_name xlsx_handler) → void?
sheet_name : string? xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
This must be called before attempting to read any cell values.
procedure
(get-sheet-names xlsx_handler) → (listof string?)
xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
procedure
(get-cell-value cell_axis xlsx_handler) → (or/c string? number?)
cell_axis : string? xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
Example:
(with-input-from-xlsx-file "workbook.xlsx" (lambda (xlsx) (load-sheet "Sheet1" xlsx) (get-cell-value "C12" xlsx)))
procedure
(get-cell-formula cell_axis xlsx_handler) → string?
cell_axis : string? xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
The cell-axis should be in the “A1” reference style.
Limitations: Currently does not support array or shared formulae.
procedure
(oa_date_number->date oa_date_number) → date?
oa_date_number : number?
Date values in xlsx files are a plain number representing the count of days since 0 January 1900.
> (date->string (oa_date_number->date 43359.1212121)) "Monday, September 17th, 2018"
> (parameterize ([date-display-format 'rfc2822]) (date->string (oa_date_number->date 44921.5601))) "Tue, 27 Dec 2022"
procedure
(get-sheet-dimension xlsx_handler)
→ (cons/c positive-integer? positive-integer?) xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
procedure
(get-sheet-rows xlsx_handler)
→ (listof (listof (or/c string? number?))) xlsx_handler : (or/c (is-a?/c read-xlsx%) (is-a?/c xlsx%))
procedure
(sheet-name-rows xlsx-file-path sheet-name)
→ (listof (listof (or/c string? number?))) xlsx-file-path : path-string? sheet-name : string?
This is the most simple function for reading xlsx data. Use it when you don’t need to do any other operations on the file.
procedure
(sheet-ref-rows xlsx-file-path sheet-index)
→ (listof (listof (or/c string? number?))) xlsx-file-path : path-string? sheet-index : exact-nonnegative-integer?
|
superclass: object% |