Skip to content

Commit 8a8482c

Browse files
committed
Add failing test for writing adjacent wide cells
1 parent bda30b2 commit 8a8482c

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

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]

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)