3 Write
write a xlsx file means instance a xlsx-data% class.
use add-sheet to fill a xlsx-data% instance and write it to file.
3.1 xlsx-data%
xlsx-data% class represent a whole xlsx file’s data.
it contains sheet data and col attibutes.
xlsx-data% have only one method: add-sheet.
sheet data just a list: (list (list cell ...) (list cell ...)...).
this is a simple xlsx-data% example without col attributes:
(let ([xlsx (new xlsx-data%)]) |
(send xlsx add-sheet '(("chenxiao" "cx") (1 2 34 100 456.34)) "Sheet1") |
3.2 col-attribute
col-attribute used to specify column’s attribute.
you can set column’s width, color by now.
col-attribute is a hash.
hash’s key is column’s dimension, value is a struct named:col-attr.
;; set column A width: 100, color: FF0000 |
(hash-set! col_attr_hash "A" (col-attr 100 "FF0000")) |
(hash-set! col_attr_hash "B" (col-attr 200 "00FF00")) |
(hash-set! col_attr_hash "C" (col-attr 200 "EF9595")) |
(hash-set! col_attr_hash "D-F" (col-attr 100 "0000FF")) |
(hash-set! col_attr_hash "7-10" (col-attr 100 "EE89CD")) |
3.3 func
procedure
(write-xlsx-file xlsx-data path) → void?
xlsx-data : (xlsx-data%) path : (path-string?)