Comments (19)
Hi @alexandrarprice ,
Have you tried to initialize the field to null or other values like:
@ExcelCell(0)
private Integer total = -1;
@ExcelCell(1)
private Float total = null;
You can use wrapper classes of primitive types with poiji.
from poiji.
Hey, thanks so much for the quick response!
We just tried this and we found it was still being overwritten as zero. If this isn't the intended behavior, we'd be happy to try our best shot at a PR!
Thanks!
In case it helps at all, here's a sample of what our object looks like:
@ExcelCellName("Cost")
private Double cost = null;
We tried it with @ExcelCell as well, same results.
Tagging teammate @mindyor as I'll be headed out on vacation this afternoon. Thanks!
from poiji.
Hmm, I can also investigate if you have a test excel file @alexandrarprice
from poiji.
Thanks for helping us take a look!
Uploading a zip (Archive.zip) with two toy files:
- sample.xlsx works, does initialize Cost automatically to null or to a number should we choose to.
// sets blank cost to null
@ExcelCellName("Cost")
private Double cost;
// sets blank cost to 12
@ExcelCellName("Cost")
private Double cost = 12d;
- sample.xls shows us 0 regardless of what we initialize cost to.
from poiji.
Using PoijiOptions.preferNullOverDefault didn't seem to help :/
from poiji.
Hi @mindyor and @alexandrarprice ,
Could you try the 1.16 snapshot for this case:
<dependency>
<groupId>com.github.ozlerhakan</groupId>
<artifactId>poiji</artifactId>
<version>1.16-SNAPSHOT</version>
</dependency>
You need to use PoijiOptions.preferNullOverDefault
to set Float, Double, Integer, Long (i.e. wrapper classes of primitive types) , java.util.Date
and String
values to null.
from poiji.
Hm, I seem unable to pull down that snapshot.
https://jcenter.bintray.com/com/github/ozlerhakan/poiji/ and https://repo.maven.apache.org/maven2/com/github/ozlerhakan/poiji/ only go up to 1.15.
from poiji.
You can see the snapshot over there: https://oss.sonatype.org/content/repositories/snapshots/com/github/ozlerhakan/poiji/
You should mention this url in your pom file as a reporsitory. You can look at this gist for details: https://gist.github.com/ktuukkan/8cf2de1e915185118c60
from poiji.
Ah, got it. Thank you.
Without preferNullOverDefault(true), the same behavior persists (defaults to 0) for XLS
With preferNullOverDefault(true), String cells are null for both XLS and XLSX.
from poiji.
So this is what you want? @mindyor
from poiji.
Sorry for not being clearer.
No, it looks like this change breaks the existing functionality for String.
from poiji.
But if we use preferNullOverDefault(true)
String values should be null. Otherwise, String fields will be assigned to an empty String. What do you think?
from poiji.
I agree, but even cells that are non-empty are being parsed in as null. Are you able to replicate this?
from poiji.
hmm, interesting, do you have a mockup excel ?
from poiji.
The excel in the zipfile attached above (sample.xls in Archive.zip) should work.
from poiji.
You can try again the same snapshot, I think I have fixed that problem.
from poiji.
Yes!! Looks good 👍 !!
from poiji.
1.16 is now available @mindyor @alexandrarprice
from poiji.
Awesome, thank you so much!!
from poiji.
Related Issues (20)
- Exception when trying to parse .xlsx file HOT 2
- How can we apply I18N internationalization , headers languages. HOT 2
- Repeated columns in @ExcelCellRange HOT 3
- Can not dateFormatter give YearMonth.class HOT 2
- Handling of multiple nested headers HOT 2
- Impossible to map values in reused @ExcellCellRange classes HOT 6
- LocalDate is always parsed to current date HOT 5
- PoijiMultiRowException currently unable to gather multiple errors HOT 7
- Stream reading HOT 3
- [FEATURE] Pojo to Excel HOT 1
- Cannot get a STRING value from a NUMERIC cell HOT 1
- Potential IAE with 4.1.1 due to deprecation fix HOT 3
- data not getting mapped for xlsx file to pojo object HOT 2
- Blanks in Excel cells are always parsed into null values when .preferNullOverDefault(true) is used HOT 2
- Reading Excel With japanese character, that include phonetic text HOT 5
- Year Issue HOT 13
- com.poiji.exception.PoijiInstantiationException: Cannot create a new instance of aadhar.StudentInfo HOT 2
- When I set up headerCount with 0, @ExcelUnknownCells does not parse correctly HOT 5
- How can I ignore external workbook references in formula HOT 18
- How can I get correct date time from sheet HOT 7
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 poiji.