• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Getting pop up after opening excel file created through Java

 
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10964
87
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7126
185
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic