Comments (4)
I did not encounter this use case as I mostly use it for two use cases: "read to Clojure data" or "write Clojure data structures to a sheet".
I agree that it does not look very elegant, though, so I understand why you want something better.
I think a better API for traversal and updates could be created around a "cursor" concept (using ideas from Haskell's lenses) that would could make this more elegant.
If you would be interested in working on it, it would be a great improvement for a V2-release.
from docjure.
is there a V2-release already?
from docjure.
I would like to have this too. My use-case is "read a somewhat tricky excel-template, fill it with some data from clojure, and then write it out". There are empty cells in the template, which resolve to nil with select-cell
so set-cell!
doesn't work. I have to call createCell
as above to set the values. After that, my second use case is the usual "read the excel, do something with it in Clojure".
This seems like a fundamental feature to me if this library wants to allow manipulation of Excel-files, not just generating them from scratch and reading them.
Generating a tricky excel-template is not a feasible option, wouldn't want to try that, but Cocjure import + export didn't break my template file, which says positive things about the underlying Apache library and docjure.
from docjure.
Hmm. As such, this is not suitable for a pull request, but here's an example for what I basically would except and want to have. It's essentially a single-cell version of the proposed change in this issue, which operates on row level.
This function either sets the value to a cell instance if one already exists for the specified location reference. Or creates a new cell object and sets the value + type then.
Caveats
- Doesn't handle the case where the whole row specified by the reference is missing.
- Could dispatch with defmulti based on the type
- Doesn't set the type for existing cell, which may be confusing.
(defn set-or-create-cell!
([sheet n val type]
(let [cellref (org.apache.poi.ss.util.CellReference. n)
r (.getRow cellref)
col (int (.getCol cellref))
row (or (.getRow sheet r) (.createRow sheet r))
cell (or (select-cell n sheet) (.createCell row col type))]
(set-cell! cell val)))
([sheet n val]
(set-or-create-cell! sheet n val org.apache.poi.ss.usermodel.Cell/CELL_TYPE_STRING)))
from docjure.
Related Issues (20)
- Generate documentation (on push) HOT 1
- Add documentation build and badge HOT 3
- Expose quotePrefixed style attribute in `create-cell-style!` HOT 2
- Reuse similar-looking CellStyles HOT 1
- New release needed to support auto-size-all-columns! documented in README.md HOT 1
- Make `dk.ative.docjure.spreadsheet/create-date-format` public
- Simplest way to place data HOT 2
- ODS file support HOT 4
- Working arond "Zip bomb detected!" HOT 1
- Error upgrading to 0.13 using java 1.8 HOT 3
- Automatically use header row to read tabular sheet HOT 1
- CVE-2019-12415 HOT 9
- Numeric text string being read as float HOT 7
- Get index with select-columns HOT 1
- Writing on an empty cell HOT 2
- SKEW formula in Excel results in exception instead of :FUNCTION_NOT_IMPLEMENTED HOT 2
- Output a formula HOT 1
- Applying styles to multiple sheets? HOT 1
- Create save to stream example in documentation
- CVE-2022-26336: org.apache.poi/poi "4.1.1" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docjure.