Skip to content

Commit 693c35a

Browse files
committed
Merge branch 'develop' for v1.3.2
2 parents bda30b2 + 09d8095 commit 693c35a

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22

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
49
### Added
510
- A lower-level, writer style interface for Apache POI.
611
- [Prototype/brainstorm](src/excel_clj/prototype.clj) of less complicated,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ common sense styling.
88

99
Lein:
1010
```
11-
[org.clojars.mjdowney/excel-clj "1.3.1"]
11+
[org.clojars.mjdowney/excel-clj "1.3.2"]
1212
```
1313

1414
- [Getting Started](#getting-started)

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject org.clojars.mjdowney/excel-clj "1.3.1"
1+
(defproject org.clojars.mjdowney/excel-clj "1.3.2"
22
:description "Generate Excel documents & PDFs from Clojure data."
33
:url "https://github.com/matthewdowney/excel-clj"
44
:license {:name "Eclipse Public License"

src/excel_clj/core.clj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,8 @@
229229
[workbook]
230230
(open (write-pdf! workbook (temp ".pdf"))))
231231

232-
(defn example []
233-
(quick-open
234-
{"Tree Sheet"
232+
(def example-workbook-data
233+
{"Tree Sheet"
235234
(tree
236235
["Mock Balance Sheet for the year ending Dec 31st, 2018"
237236
tree/mock-balance-sheet])
@@ -243,11 +242,13 @@
243242
{"Date" "2018-03-01" "% Return" 0.07M "USD" 2100.66666666M}])
244243

245244
"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}]
247246
["First Column Value" "Second Column Value"]
248247
["This" "Row" "Has" "Its" "Own"
249-
{:value "Format" :style {:font {:bold true}}}]]}))
248+
{:value "Format" :style {:font {:bold true}}}]]})
250249

250+
(defn example []
251+
(quick-open example-workbook-data))
251252

252253
(comment
253254
;; This should open an Excel workbook
@@ -259,9 +260,9 @@
259260
(open (convert-pdf! (example) (temp ".pdf")))
260261

261262
;; 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)}))})
265266

266267
;; Ballpark performance test
267268
(dotimes [_ 5]

src/excel_clj/poi.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
poi-cell (.createCell poi-row cidx)]
122122

123123
(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))
124127
(let [ridx @row-cursor
125128
cra (CellRangeAddress.
126129
ridx (dec (+ ridx height))
@@ -213,7 +216,14 @@
213216
;; This one won't be visible, because it's hidden behind the tall cell
214217
(write! t "1")
215218
(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+
)
217227

218228

219229
(defn performance-test

test/excel_clj/core_test.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns excel-clj.core-test
22
(:require [clojure.test :refer :all]
3-
[excel-clj.core :refer :all]))
3+
[excel-clj.core :refer :all]
4+
[clojure.java.io :as io]))
45

56
(deftest table-test
67
(let [data [{"Date" "2018-01-01" "% Return" 0.05M "USD" 1500.5005M}
@@ -29,3 +30,12 @@
2930
["" 5 2]
3031
["Tree 2" nil nil]
3132
["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)))))

0 commit comments

Comments
 (0)