Skip to content

Commit 2e0e62b

Browse files
committed
Get rid of problematic rhizome dependency & fix column resizing
1 parent 693c35a commit 2e0e62b

File tree

5 files changed

+16
-30
lines changed

5 files changed

+16
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## [1.3.3] - 2020-07-11
4+
### Fixed
5+
- Bug where columns would only auto resize up until 'J'
6+
- Unnecessary Rhizome dependency causing headaches in headless environments
7+
38
## [1.3.2] - 2020-04-15
49
### Fixed
510
- Bug introduced in v1.3.1 where adjacent cells with width > 1 cause an

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.2"]
11+
[org.clojars.mjdowney/excel-clj "1.3.3"]
1212
```
1313

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

project.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
(defproject org.clojars.mjdowney/excel-clj "1.3.2"
1+
(defproject org.clojars.mjdowney/excel-clj "1.3.3"
22
:description "Generate Excel documents & PDFs from Clojure data."
33
:url "https://github.com/matthewdowney/excel-clj"
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:dependencies [[org.clojure/clojure "1.10.1"]
77
[com.taoensso/tufte "2.0.1"]
8-
[rhizome "0.2.9"]
98
[org.apache.poi/poi-ooxml "4.0.0"]
109
[org.jodconverter/jodconverter-core "4.0.0-RELEASE"]])

src/excel_clj/prototype.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@
104104

105105

106106
(defn- write-rows!
107-
"Write the rows via the given sheet-writer, returning the number of rows
108-
written."
107+
"Write the rows via the given sheet-writer, returning [the number of rows
108+
written, number of columns written]."
109109
[sheet-writer rows-seq]
110110
(reduce
111-
(fn [n next-row]
111+
(fn [[rows cols] next-row]
112112
(doseq [cell next-row]
113113
(let [{:keys [width height]} (dims cell)]
114114
(poi/write! sheet-writer (data cell) (style cell) width height)))
115115
(poi/newline! sheet-writer)
116-
(inc n))
117-
0
116+
[(inc rows) (max cols (count next-row))])
117+
[0 0]
118118
rows-seq))
119119

120120

@@ -129,10 +129,10 @@
129129
(with-open [w (poi/writer f)]
130130
(doseq [[nm rows] workbook
131131
:let [sh (poi/sheet-writer w nm)
132-
n-written (write-rows! sh rows)]]
132+
[rows-written cols-written] (write-rows! sh rows)]]
133133
;; Only auto-size columns for small sheets, otherwise it takes forever
134-
(when (< n-written 2000)
135-
(dotimes [i 10]
134+
(when (< rows-written 2000)
135+
(dotimes [i cols-written]
136136
(poi/autosize!! sh i)))))
137137
f))
138138

src/excel_clj/style.clj

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@
5858
(coerce-to-obj
5959
workbook :font {:bold true :font-height-in-points 10}))))"
6060
{:author "Matthew Downey"}
61-
(:require [clojure.string :as string]
62-
[clojure.reflect :as reflect]
63-
[rhizome.viz :as viz])
61+
(:require [clojure.string :as string])
6462
(:import (org.apache.poi.ss.usermodel
6563
DataFormat BorderStyle HorizontalAlignment FontUnderline
6664
FillPatternType)
@@ -344,19 +342,3 @@
344342
(def default-tree-total-formatters
345343
{0 {:font {:bold true} :border-top :medium}
346344
1 {:border-top :thin :border-bottom :thin}})
347-
348-
(defn example
349-
"If one wanted to visualize all of the nested setters & POI objects...
350-
Keep in mind that this requires $ apt-get install graphviz"
351-
[]
352-
(let [param-type (fn [setter] (resolve (first (:parameter-types setter))))
353-
is-setter? (fn [{:keys [name parameter-types]}]
354-
(and (string/starts-with? (str name) "set")
355-
(= 1 (count parameter-types))))
356-
setters (fn [class]
357-
(filter is-setter? (#'reflect/declared-methods class)))
358-
cell-style (first
359-
(filter #(= 'setCellStyle (:name %)) (setters XSSFCell)))]
360-
(viz/view-tree
361-
#(instance? Class (param-type %)) (comp setters param-type) cell-style
362-
:node->descriptor #(->{:label ((juxt :name :parameter-types) %)}))))

0 commit comments

Comments
 (0)