mjul / docjure

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

Get index with select-columns #90

Closed lucasemmoreira closed 4 years ago

lucasemmoreira commented 4 years ago

Hi there! Very nice lib!

Quick question: I would like to know if it is possible to get the index value with other column values. For example:


(->> (load-workbook "spreadsheet.xlsx")
     (select-sheet "Price List")
     (select-columns {:Index? :A :name, :B :price}))

;=> [{:Index? 0 :name "Foo Widget", :price 100}, {:Index? 1 :name "Bar Widget", :price 200}]

Where :Index? would be a key to reference it.

I tried with :Index with no luck.

Thx!

mjul commented 4 years ago

If you look at the code for select-columns and project-cell you will see that the index is discarded after getting the name. Returning it would be quite straightforward if you write a new select-columns-with-index function in your client application from the few lines of code in these two functions.