Comments (6)
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.
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.
from excel-streaming-reader.
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.
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.
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.
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)
- The supplied data appears to be in the OLE2 Format HOT 2
- Getting org.apache.poi.xssf.model.SharedStringsTable.getEntryAt(I) Error with POI 5.0.0 HOT 4
- New release planned with Apache POI 5.x (4.1.2 contains vulnerabilities)? HOT 1
- spliterator is not supported with Apache POI 5.2.0 (Unsupported operation getPhysicalNumberOfRows) HOT 1
- 内存溢出问题
- StreamingWorkbook#getSheetIndex(String) and StreamingWorkbook#getSheet(String) behavior is inconsistent with poi-ooxml HOT 6
- This cannot be used for reading which has image HOT 1
- Can I get data formateed value from a numberic cell HOT 2
- Can I get data formateed value from a numberic cell
- NoSuchMethodError on getSharedStringsTable HOT 1
- FileNotFoundException exception for MultipartFile resource file
- Unable to read xlsx file using Excel steaming reader HOT 2
- read picture HOT 5
- Unable read excell cell text if cell has line break HOT 1
- Is this project still active or should we look for alternatives? HOT 3
- High CPU utilisation spikes recorded HOT 3
- Unable to load the cells which are blank HOT 5
- Unable to read large excel files HOT 6
- XSSFWorkbook change orientation to landscape
- `org.xml.sax.SAXNotRecognizedException: http://xml.org/sax/properties/ on Android
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 excel-streaming-reader.