Coder Social home page Coder Social logo

Comments (19)

ozlerhakan avatar ozlerhakan commented on August 22, 2024

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.

alexandrarprice avatar alexandrarprice commented on August 22, 2024

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.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

Hmm, I can also investigate if you have a test excel file @alexandrarprice

from poiji.

mindyor avatar mindyor commented on August 22, 2024

Thanks for helping us take a look!

Uploading a zip (Archive.zip) with two toy files:

  1. 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;
  1. sample.xls shows us 0 regardless of what we initialize cost to.

from poiji.

mindyor avatar mindyor commented on August 22, 2024

Using PoijiOptions.preferNullOverDefault didn't seem to help :/

from poiji.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

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.

mindyor avatar mindyor commented on August 22, 2024

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.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

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.

mindyor avatar mindyor commented on August 22, 2024

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.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

So this is what you want? @mindyor

from poiji.

mindyor avatar mindyor commented on August 22, 2024

Sorry for not being clearer.
No, it looks like this change breaks the existing functionality for String.

from poiji.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

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.

mindyor avatar mindyor commented on August 22, 2024

I agree, but even cells that are non-empty are being parsed in as null. Are you able to replicate this?

from poiji.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

hmm, interesting, do you have a mockup excel ?

from poiji.

mindyor avatar mindyor commented on August 22, 2024

The excel in the zipfile attached above (sample.xls in Archive.zip) should work.

from poiji.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

You can try again the same snapshot, I think I have fixed that problem.

from poiji.

mindyor avatar mindyor commented on August 22, 2024

Yes!! Looks good 👍 !!

from poiji.

ozlerhakan avatar ozlerhakan commented on August 22, 2024

1.16 is now available @mindyor @alexandrarprice

from poiji.

alexandrarprice avatar alexandrarprice commented on August 22, 2024

Awesome, thank you so much!!

from poiji.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.