Giter Club home page Giter Club logo

Comments (6)

monitorjbl avatar monitorjbl commented on August 23, 2024

I'm not sure what the issue is here, exactly. If you read 0007 as a number, you should get 7. If you read it as a string, you should get 0007. Java doesn't differentiate between numeric the values 0007 and 7; they are equivalent.

I wrote a unit test to verify that this works this way, you're welcome to take a look.

from excel-streaming-reader.

hugomarques avatar hugomarques commented on August 23, 2024

I've created a testCase for this issue.
The problem actually happens with the getCellType method. Even if I format as a String in the xlsx file I'll still receive a Numeric cell. So if my logic depends to discover the type to use the correct getCellValue() it will break. Example:

if (Cell.CELL_TYPE_STRING == r2.getCell(0).getCellType()) {
r2.getCell(0).getStringCellValue();
}

Even if I want to consider 007 as a String it will not since the cell type returns Numeric. Maybe that's the expected behaviour for most use cases but I thought it was worth to discuss with you.

I've pushed a test case for that on my fork.

https://github.com/hugomarques/excel-streaming-reader/commit/5085e728d5e0ce04ceb58d56f728e4ba59c6af17

from excel-streaming-reader.

monitorjbl avatar monitorjbl commented on August 23, 2024

Ah, I see. I can't get Libre Office to treat that value as anything but numeric. Whenever I type in 0007, it gets automatically converted to 7. The only way I can get it to keep the leading zeros is to put a single quote in front of IT. How did you do it?

from excel-streaming-reader.

hugomarques avatar hugomarques commented on August 23, 2024

I formatted the cell on excel to be text type or even general.
To solve this issue I'm thinking if does make sense to think only about String types and let the client decide if he should pick as a String or Number.

from excel-streaming-reader.

monitorjbl avatar monitorjbl commented on August 23, 2024

Yeah, I wanted to have some kind of check for cell type. I wasn't able to find any intrinsic property at the time in the XML so I went with a regex check. I can take another look though.

Regardless, nothing is stopping the user from treating the cell as a number or a string in this case. Both method calls are valid.

from excel-streaming-reader.

monitorjbl avatar monitorjbl commented on August 23, 2024

Found a solution that appears to work for this. I've added your type checks to my unit test. Can you take a look and see if it's working for you as well?

from excel-streaming-reader.

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.