On this page:
2.1 Generate a xlsx file
2.2 Read a xlsx file
2.3 Read a xlsx file, modify something and Write back

2 Basic Example🔗ℹ

2.1 Generate a xlsx file🔗ℹ

(write-xlsx

  "basic.xlsx"

  (lambda ()

    (add-data-sheet "Sheet1" '(("month1" "month2" "month3" "month4" "real")))

 

    (add-data-sheet "Sheet2" '((201601 100 110 1110 6.9)))))

1. All operations in write-xlsx’s lambda scope.

2. Specify file name, sheet name, have same count’s list data, done.

2.2 Read a xlsx file🔗ℹ

(read-xlsx

  "basic_write.xlsx"

  (lambda ()

    (check-equal? (get-sheet-name-list) '("Sheet1" "Sheet2"))

 

    (with-sheet-ref

    0

    (lambda ()

      (check-equal? (get-row 1) '("month1" "month2" "month3" "month4" "real"))))

 

    (with-sheet-ref

    1

    (lambda ()

      (check-equal? (get-row 1) '(201601 100 110 1110 6.9))))))

Navigate to a specific sheet have two ways: use index or name

1. use sheet index: ****-ref, index from 0

(with-sheet-ref

  sheet_index

  (lambda () ...))

2. use sheet name: ****-name

(with-sheet-name

  sheet_name

  (lambda () ...))

2.3 Read a xlsx file, modify something and Write back🔗ℹ

(read-and-write-xlsx

  basic_write_file

  basic_read_and_write_file

  (lambda ()

    (check-equal? (get-sheet-name-list) '("Sheet1" "Sheet2"))

 

    (with-sheet-ref

    0

    (lambda ()

      (set-cell-value! "B1" "John")

      (check-equal? (get-row 1) '("month1" "John" "month3" "month4" "real"))))

 

    (with-sheet-ref

    1

    (lambda ()

      (check-equal? (get-row 1) '(201601 100 110 1110 6.9))))

      ))

The first arg is read file, second is the write back file, these two can be a same file, if you want to replace the oringinal.