Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Getting pop up after opening excel file created through Java  RSS feed

 
Ranch Hand
Posts: 52
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i used below code to create file,



File is getting created successfully, but when i open it manually just to see i am getting pop saying "the file format and extension of 'Test.xls' does not match".

Please refer attached image.
File.JPG
[Thumbnail for File.JPG]
 
Bartender
Posts: 4518
50
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you've created a file but just because the file name ends with ".xls" does not mean it's an Excel file.

If you really want to read/write an Excel file the best way to do it is with the Apache POI library. It is not a particularly simple library though and would probably present difficulties to a Java beginner.

Another way to approach the problem is by writing out a CSV (comma separated variable) file which is a basic text file separating columns of data with commas. Excel can read and write CSV files. You won't need a library for this.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understood it, but here i want to use POI only.
Can you please tell me how can i resolve it.
I am trying to get answers from different sites but its not working.

Thanks.
 
Sheriff
Posts: 23640
48
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far you have only created an empty file. But... Carey recommended you could use POI, and you said you wanted to use POI. So it looks like that's settled then. I don't see what's left to be resolved. Go ahead and use POI to write the data into your Excel file.

Of course if you run into problems, the Ranch is here to help.
 
Saloon Keeper
Posts: 4678
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Swapnil Sanghai wrote:I am trying to get answers from different sites but its not working.


Tells us what you did, and what exactly "it's not working" means. Post the code you have so far, and how it is and how it isn't working according to your expectations.
 
Sheriff
Posts: 5015
138
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are some examples for how to write an Excel file with POI.  Tell us what problems you run into.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!