• Post Reply Bookmark Topic Watch Topic
  • New Topic

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: 3852
47
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: 23429
46
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: 4280
106
  • 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: 4627
129
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!