|
1 |
| -## excel-clj |
| 1 | +# excel-clj |
2 | 2 |
|
3 |
| -Purpose: declarative creation of Excel spreadsheets / PDFs with Clojure from |
4 |
| -higher level abstractions (tree, table) or via a manual grid specification, with |
5 |
| -boilerplate-free common sense styling. |
| 3 | +Declarative generation of Excel documents & PDFs with Clojure from higher level |
| 4 | +abstractions (tree, table) or via a manual grid specification, with boilerplate-free |
| 5 | +common sense styling. |
| 6 | + |
| 7 | +[CHANGELOG](CHANGELOG.md) | Uses [Break Versioning](https://github.com/ptaoussanis/encore/blob/master/BREAK-VERSIONING.md) |
| 8 | + |
| 9 | +Lein: |
| 10 | +``` |
| 11 | +[org.clojars.mjdowney/excel-clj "1.0.0"] |
| 12 | +``` |
| 13 | + |
| 14 | +- [Getting Started](#getting-started) |
| 15 | + - [Tables](#tables) |
| 16 | + - [Trees](#trees) |
| 17 | + - [PDF Generation](#pdf-generation) |
| 18 | + - [Table Styling](#table-styling) |
| 19 | + - [Tree Styling](#tree-styling) |
| 20 | + - [Manual Styling](#manual-styling) |
| 21 | + - [Grid Format & Cell Merging](#grid-format-&-cell-merging) |
| 22 | +- [Roadmap](#roadmap) |
| 23 | + - [Tree flexibility](#roadmap) |
| 24 | + - [Templates](#roadmap) |
| 25 | + - [Reading & editing](#roadmap) |
| 26 | + - [Formulas](#roadmap) |
| 27 | + |
| 28 | +## Getting Started |
6 | 29 |
|
7 | 30 | All of the namespaces have an `example` function at the end; they're intended to
|
8 | 31 | be browsable and easy to interact with to glean information beyond what's here
|
9 | 32 | in a the readme.
|
10 | 33 |
|
11 | 34 | Start by skimming this and then browsing [core.clj](src/excel_clj/core.clj).
|
12 | 35 |
|
| 36 | +Tests are run with |
| 37 | + |
| 38 | +```clojure |
| 39 | +lein test |
| 40 | +``` |
| 41 | + |
13 | 42 | ### Tables
|
14 | 43 | Though Excel is much more than a program for designing tabular layouts, a table
|
15 | 44 | is a common abstraction that we impose on our data.
|
@@ -157,3 +186,62 @@ that includes optional style data / cell merging instructions.
|
157 | 186 | ```
|
158 | 187 |
|
159 | 188 | 
|
| 189 | + |
| 190 | +## Roadmap |
| 191 | +- Tree flexibility. [tree.clj](src/excel_clj/tree.clj) should be able to work |
| 192 | + with any data shape given the same functions as [`clojure.core/tree-seq`](https://clojuredocs.org/clojure.core/tree-seq). |
| 193 | + Additionally, it should provide hooks for custom ways to aggregate columns |
| 194 | + (instead of expecting `Number` data and summing it) and whether or not to display |
| 195 | + sub-category level totals vs just grand totals. |
| 196 | + |
| 197 | +- Templates! There's no reason to do all of the styling work programmatically. |
| 198 | + We should be able to download [some cool Google Sheets template](https://docs.google.com/spreadsheets/u/0/?usp=mkt_sheets_tpl) |
| 199 | + as an `.xlsx` file, edit it to indicate where `excel-clj` should fill in tables, |
| 200 | + trees, or individual cells, and then write code that reads the template from a |
| 201 | + `resources/some-template.xlsx` and produces a filled in sheet. |
| 202 | + |
| 203 | + Not at all a fully formed spec yet, but something along the lines of filling |
| 204 | + in the following sheet: |
| 205 | + |
| 206 | +  |
| 207 | + |
| 208 | + Using some simple data: |
| 209 | + ```clojure |
| 210 | + {:title "The Title" |
| 211 | + :start-date (Date. (- (System/currentTimeMillis) (* 1000 60 60 24 7))) |
| 212 | + :end-date (Date.) |
| 213 | + :employee-name "Foo" |
| 214 | + :employee-id "Bar" |
| 215 | + :manager-name "Baz" |
| 216 | + :department "Accounting" |
| 217 | + :expense-purpose "Trip" |
| 218 | + :tbl [{:date (Date.) :category "Cat A" :desc "Misc expenses" |
| 219 | + :notes "" :amount 500.00M} |
| 220 | + {:date (Date.) :category "Cat B" :desc "Other expenses" |
| 221 | + :notes "" :amount 100.00M}]} |
| 222 | + ``` |
| 223 | + |
| 224 | + To get the following result: |
| 225 | + |
| 226 | +  |
| 227 | + |
| 228 | +- Reading & editing existing spradsheets. This should go hand in hand with |
| 229 | + template generation. |
| 230 | + |
| 231 | +- Formulas! We don't have them. I'm envisioning a syntax where a table column |
| 232 | + or a cell contain a `:value` of `(excel/formula ...)`. The interior of the |
| 233 | + formula could allow relative coordinate generation with the placeholders `*x*` |
| 234 | + and `*y*` — which could be operated on to find relative coordinates (e.g. |
| 235 | + `(- *x* 2)`) — and would then be replaced during rendering with the column and |
| 236 | + row. E.g. |
| 237 | + |
| 238 | + ```clojure |
| 239 | + (def table-data |
| 240 | + [{"Foos" 10, "Bars" 5, "Total" (excel/formula "=(- *x* 2)*y* + (- *x* 1)*y*")} |
| 241 | + {"Foos" 12, "Bars" 8, "Total" (excel/formula "=(- *x* 2)*y* + (- *x* 1)*y*")}]) |
| 242 | + ``` |
| 243 | + |
| 244 | + would result in the formulas being rendered in the C column after the title |
| 245 | + row, the first being `=A1+B1` and the second being `=A2+B2`. |
| 246 | + |
| 247 | +- Java wrapper? Uncertain if this would be useful / how it would look. |
0 commit comments