File tree Expand file tree Collapse file tree 6 files changed +39
-13
lines changed Expand file tree Collapse file tree 6 files changed +39
-13
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
- ## [ 1.3.0] - 2020-04-05
3
+ ## [ 1.3.2] - 2020-04-15
4
+ ### Fixed
5
+ - Bug introduced in v1.3.1 where adjacent cells with width > 1 cause an
6
+ exception.
7
+
8
+ ## [ 1.3.1] - 2020-04-05
4
9
### Added
5
10
- A lower-level, writer style interface for Apache POI.
6
11
- [ Prototype/brainstorm] ( src/excel_clj/prototype.clj ) of less complicated,
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ common sense styling.
8
8
9
9
Lein:
10
10
```
11
- [org.clojars.mjdowney/excel-clj "1.3.1 "]
11
+ [org.clojars.mjdowney/excel-clj "1.3.2 "]
12
12
```
13
13
14
14
- [ Getting Started] ( #getting-started )
Original file line number Diff line number Diff line change 1
- (defproject org.clojars.mjdowney /excel-clj " 1.3.1 "
1
+ (defproject org.clojars.mjdowney /excel-clj " 1.3.2 "
2
2
:description " Generate Excel documents & PDFs from Clojure data."
3
3
:url " https://github.com/matthewdowney/excel-clj"
4
4
:license {:name " Eclipse Public License"
Original file line number Diff line number Diff line change 229
229
[workbook]
230
230
(open (write-pdf! workbook (temp " .pdf" ))))
231
231
232
- (defn example []
233
- (quick-open
234
- {" Tree Sheet"
232
+ (def example-workbook-data
233
+ {" Tree Sheet"
235
234
(tree
236
235
[" Mock Balance Sheet for the year ending Dec 31st, 2018"
237
236
tree/mock-balance-sheet])
243
242
{" Date" " 2018-03-01" " % Return" 0.07M " USD" 2100.66666666M }])
244
243
245
244
" Freeform Grid Sheet"
246
- [[" First Column " " Second Column " {:value " A few merged " :width 3 }]
245
+ [[" First" " Second" {:value " Wide " :width 2 } { :value " Wider " :width 3 }]
247
246
[" First Column Value" " Second Column Value" ]
248
247
[" This" " Row" " Has" " Its" " Own"
249
- {:value " Format" :style {:font {:bold true }}}]]}))
248
+ {:value " Format" :style {:font {:bold true }}}]]})
250
249
250
+ (defn example []
251
+ (quick-open example-workbook-data))
251
252
252
253
(comment
253
254
; ; This should open an Excel workbook
259
260
(open (convert-pdf! (example ) (temp " .pdf" )))
260
261
261
262
; ; Expose ordering / styling issues in v1.2.X
262
- (quick-open {" Test" (table
263
- (for [x (range 10000 )]
264
- {" N" x, " N^2" (* x x), " N^3" (* x x x)}))})
263
+ (quick-open {" Test" (table
264
+ (for [x (range 10000 )]
265
+ {" N" x, " N^2" (* x x), " N^3" (* x x x)}))})
265
266
266
267
; ; Ballpark performance test
267
268
(dotimes [_ 5 ]
Original file line number Diff line number Diff line change 121
121
poi-cell (.createCell poi-row cidx)]
122
122
123
123
(when (or (> width 1 ) (> height 1 ))
124
+ ; ; If the width is > 1, move the cursor along so that the next write on
125
+ ; ; this row happens in the next free cell, skipping the merged area
126
+ (vswap! col-cursor + (dec width))
124
127
(let [ridx @row-cursor
125
128
cra (CellRangeAddress.
126
129
ridx (dec (+ ridx height))
213
216
; ; This one won't be visible, because it's hidden behind the tall cell
214
217
(write! t " 1" )
215
218
(write! t " 2" )
216
- (write! t " 3" ))))
219
+ (write! t " 3" )
220
+
221
+ (newline! t)
222
+ (write! t " Wide" nil 2 1 )
223
+ (write! t " Wider" nil 3 1 )
224
+ (write! t " Much Wider" nil 5 1 )))
225
+
226
+ )
217
227
218
228
219
229
(defn performance-test
Original file line number Diff line number Diff line change 1
1
(ns excel-clj.core-test
2
2
(:require [clojure.test :refer :all ]
3
- [excel-clj.core :refer :all ]))
3
+ [excel-clj.core :refer :all ]
4
+ [clojure.java.io :as io]))
4
5
5
6
(deftest table-test
6
7
(let [data [{" Date" " 2018-01-01" " % Return" 0.05M " USD" 1500.5005M }
29
30
[" " 5 2 ]
30
31
[" Tree 2" nil nil ]
31
32
[" Child" -2 -1 ]]))))
33
+
34
+
35
+ (deftest example-test
36
+ (let [temp-file (io/file (#'excel-clj.core/temp " .xlsx" ))]
37
+ (try
38
+ (testing " Example code snippet writes successfully."
39
+ (write! example-workbook-data temp-file))
40
+ (finally
41
+ (io/delete-file temp-file)))))
You can’t perform that action at this time.
0 commit comments