|
23 | 23 | - [What are the options for styling?](#what-are-the-options-for-styling?)
|
24 | 24 | - [Grids](#grids)
|
25 | 25 | - [Templates](#templates)
|
| 26 | + - [Accessing The `Sheet`](#accessing-the-sheet) |
26 | 27 | - [Roadmap](#roadmap)
|
27 | 28 | - [Development](#development)
|
28 | 29 | - [Unit Tests](#unit-tests)
|
@@ -271,6 +272,41 @@ For example, you can try:
|
271 | 272 | (excel/append! new-data template "filled-in-template.xlsx"))
|
272 | 273 | ```
|
273 | 274 |
|
| 275 | +### Accessing The `Sheet` |
| 276 | + |
| 277 | +There is not a way to directly access the `Sheet` object using the API. Instead, |
| 278 | +following the function `excel-clj.file/write*` as an example, open an Excel file |
| 279 | +and create the `Sheet`. |
| 280 | + |
| 281 | +```clojure |
| 282 | +(require '[clojure.java.io :as io]) |
| 283 | +(require '[excel-clj.core :as excel]) |
| 284 | +(require '[excel-clj.file :as file]) |
| 285 | +(require '[excel-clj.poi :as poi]) |
| 286 | +(import '[org.apache.poi.ss.usermodel Sheet]) |
| 287 | + |
| 288 | +(let [worksheet-data (excel/table-grid [{:name "Trip 1" |
| 289 | + :miles 34.5 |
| 290 | + :max-speed 15.2} |
| 291 | + {:name "Trip 2" |
| 292 | + :miles 14.1 |
| 293 | + :max-speed 35.2} |
| 294 | + {:name "Trip 3" |
| 295 | + :miles 18.9 |
| 296 | + :max-speed 21.1}]) |
| 297 | + xlsx-filename (file/temp ".xlsx") |
| 298 | + excel-file (io/file xlsx-filename)] |
| 299 | + (with-open [poi-writer (poi/writer excel-file)] |
| 300 | + (let [sheet-writer (poi/sheet-writer poi-writer "Sheet1") |
| 301 | + worksheet ^Sheet (:sheet sheet-writer)] |
| 302 | + (doto worksheet |
| 303 | + (.setColumnWidth 1 500) |
| 304 | + (.createFreezePane 0 1)) |
| 305 | + (file/write-rows! sheet-writer worksheet-data))) |
| 306 | + ;; optionally open the created file |
| 307 | + (file/open excel-file)) |
| 308 | +``` |
| 309 | + |
274 | 310 | ## Roadmap
|
275 | 311 |
|
276 | 312 | - A way to read in a saved workbook to the `{sheet-name [[cell]]}` format. I'm
|
|
0 commit comments