mjul / docjure

Read and write Office documents from Clojure
MIT License
622 stars 129 forks source link

Can't seem to modify .xls file #17

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hello!

I'm new to Clojure so I'm sure this is my fault but I'm just kind of too clueless to figure out what might be causing it.

Right now I have two simple functions for testing reading/writing for an excel file.

(defn a []
  (let [workbook (load-workbook "/home/ubikation/src/clojure/excel-test/products.xls")
        a1 (-> workbook (.getSheetAt 0) (.getRow 0) (.getCell 0))]
    (set-cell! a1 "foo")
    (println (.getStringCellValue a1))))

(defn z []
  (let [workbook (load-workbook "/home/ubikation/src/clojure/excel-test/products.xls")
        a1 (-> workbook (.getSheetAt 0) (.getRow 0) (.getCell 0))]
    (println (.getStringCellValue a1))))

The first one works, and prints "foo" but the second one will always return the initial value of the xls file.

Perhaps there is a non-local file bind? I'm not really sure what's going on or how to figure out what I'm doing wrong.

Sorry if this is the wrong location for this.

ghost commented 10 years ago

Sorry, turns out I forgot to save the workbook:

(defn a []
  (let [workbook (load-workbook "/home/ubikation/src/clojure/excel-test/products.xls")
        a1 (-> workbook (.getSheetAt 0) (.getRow 0) (.getCell 0))]
    (do (set-cell! a1 "foo")
        (save-workbook! "/home/ubikation/src/clojure/excel-test/products.xls" workbook))))