On this page:
6.1 cell/  cell-value?
6.2 Example Sheet Data
6.3 Skip the with-sheet*
6.4 get-cell/  set-cell!
6.5 get-row/  set-row!
6.6 get-rows/  set-rows!
6.7 get-col/  set-col!
6.8 get-cols/  set-cols!
6.9 get-rows-count/  get-cols-count
8.12

6 Access Data🔗ℹ

6.1 cell/cell-value?🔗ℹ

cell is the XLSX’s cell’s name:

First is the column’s index identified by the alphabet from "A".

Second is the row’s index identified by the number from 1.

Example: Cell in the second row, the third column, so cell is "C2".

cell-value can be these type: string, number, date.

6.2 Example Sheet Data🔗ℹ

(add-data-sheet "sheet1" '(
                            (1 2 3)
                            (4 5 6)
                          ))

6.3 Skip the with-sheet*🔗ℹ

If not have a mass access on a sheet, you can get/set data a sheet directly, not need in a with-sheet* scope.

Example:

1. Normally get a cell’s value:
(with-sheet (lambda () (get-cell "A1") ...))

2. Direct get a cell’s value:
(get-sheet-ref-cell 0 "A1")

There are 3 ways to locate a sheet:

sheet-ref: use sheet index, start from 0.

sheet-name: use sheet name, match exactly.

sheet-*name*: use part of sheet name, locate first matched sheet name.

Example:

get-cell have 3 direct function:
get-sheet-ref-cell, get-sheet-name-cell, get-sheet-*name*-cell

6.4 get-cell/set-cell!🔗ℹ

get-cell (-> string? cell-value?)
 
(check-equals (get-cell "B2") 5)

Direct function:
get-sheet-ref-cell, get-sheet-name-cell, get-sheet-*name*-cell

set-cell! (-> string? cell-value? void?)
 
(set-cell! "C1" 8)

Direct function:
set-sheet-ref-cell!, set-sheet-name-cell!, set-sheet-*name*-cell!

6.5 get-row/set-row!🔗ℹ

Row’s index from 1.

get-row (-> natural? (listof cell-value?))
 
(check-equal? (get-row 1) '(1 2 3))

Direct function:
get-sheet-ref-row, get-sheet-name-row, get-sheet-*name*-row

set-row! (-> natural? (listof cell-value?) void?)
 
(set-row! 1 '(7 8 9))

Direct function:
set-sheet-ref-row!, set-sheet-name-row!, set-sheet-*name*-row!

6.6 get-rows/set-rows!🔗ℹ

get-rows (-> (listof (listof cell-value?)))
 
(check-equal? (get-rows) '((1 2 3) (4 5 6)))

Direct function:
get-sheet-ref-rows, get-sheet-name-rows, get-sheet-*name*-rows

set-rows! (-> (listof (listof cell-value?)) void?)
 
(set-rows! '((1 2 3) (7 8 9)))

Direct function:
set-sheet-ref-rows!, set-sheet-name-rows!, set-sheet-*name*-rows!

6.7 get-col/set-col!🔗ℹ

Col’s index from 1.

get-col (-> natural? (listof cell-value?))
 
(check-equal? (get-col 1) '(1 4))
(check-equal? (get-col 2) '(2 5))
(check-equal? (get-col 3) '(3 6))

Direct function:
get-sheet-ref-col, get-sheet-name-col, get-sheet-*name*-col

set-col! (-> natural? (listof cell-value?) void?)
 
(set-col! 1 '(7 8))

Direct function:
set-sheet-ref-col!, set-sheet-name-col!, set-sheet-*name*-col!

6.8 get-cols/set-cols!🔗ℹ

get-cols (-> (listof (listof cell-value?)))
 
(check-equal? (get-cols) '((1 4) (2 5) (3 6)))

Direct function:
get-sheet-ref-cols, get-sheet-name-cols, get-sheet-*name*-cols

set-cols! (-> (listof (listof cell-value?)) void?)
 
(set-cols! '((7 8) (9 0) (1 2)))

Direct function:
set-sheet-ref-cols!, set-sheet-name-cols!, set-sheet-*name*-cols!

6.9 get-rows-count/get-cols-count🔗ℹ

get-rows-count (-> natural?)
get-cols-count (-> natural?)
 
(check-equal? (get-rows-count) 2)
(check-equal? (get-cols-count) 3)

Direct function:
get-sheet-ref-rows-count, get-sheet-name-rows-count, get-sheet-*name*-rows-count
get-sheet-ref-cols-count, get-sheet-name-cols-count, get-sheet-*name*-cols-count