Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion - read the entire workbook contents, instead of just the selected cell-names #2

Open
edgargoncalves opened this issue Jul 24, 2010 · 1 comment

Comments

@edgargoncalves
Copy link

In order to provide a complete reader, I needed this function. Maybe you'll want to use it in docjure, or write a similar one (note that I made keywords, but that's not exactly required):

(defn process-workbook [#^Workbook wb]
  "Returns a vector with maps for each sheet (a name and a vector with maps for each row, in the form [{:a1 valA1, :c2 valC2, ...}, ...]."
  (vec
   (for [sheet (sheet-seq wb)]
     (hash-map :name (sheet-name sheet)
           :rows (let [rows (vec
                 (for [row (into-seq sheet)]
                   (map read-cell row)))
               headers (map keyword (first rows))
               data (rest rows)]
               (map #(zipmap headers %) data))))))
@mjul
Copy link
Owner

mjul commented Jul 26, 2010

Nice code. I have another use case for something similar in one of the clients we wrote, so I will think about combining the two ideas.

Cheers, Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants