This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How to identify the Microsoft office version + POI

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using POI Version 3.6. and i am reading excel files using POI.

But is there anyway i can identify the version of excel file. because sometime .xls extension also needs XSSF as they are using the features of office 2007.

Regards,
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really need to know what format it is? The classes in the org.apache.poi.ss.usermodel package can handle both file formats.

If you do, try reading the file as a ZIP file (which the Office 2007 formats actually are) using the classes in java.util.zip; if you get an exception, then it's a binary (pre-office 2007) file.
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i read ?

Below is my code.

Currently i am just checking the extension. if the file extension is xls then call readExcel if its xlsx then call readExcel2007

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to do all that in your code, that's what the org.apache.poi.ss.usermodel package is for.
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how do i read xls file.

I am not able to read xls. file using XSSF i need to use HSSF
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok. i got it.



Thanks
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
beautiful

 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!