简体   繁体   中英

Create a Connection between excel and Java

I have been working on a program where I need to save information into excel and then take the info from the excel spreadsheet that was saved eariler by a user.

My problem is that I am a new programmer so I dont know how to create a connection with excel and then save it as an excel file and retreive data from the file.

PS: I am working on the jframe

Excel and Java weren't exactly built to interact with each other but it can be done.

If you save the spreadsheet as a .csv file it can be interpreted by a Java program, like this: http://www.mkyong.com/java/how-to-read-and-parse-csv-file-in-java/

That being said, it's much easier to work with JSON in Java (in my opinion) so once you've got a CSV file you can use this website to convert it: http://www.csvjson.com/csv2json Unfortunately this way you won't be able to use a JSON in Excel, whereas with the other way you can open the file for writing, write to it, close it, and be able to open it again with Excel.

If you have a choice, it would be better to use C# since it was also made by Microsoft and they like to make it easier to interact with their own file types.

Check Apache POI for such need. Indeed Apache POI is a java library allowing to manipulate Microsoft Documents such as Excel.

For Excel here is the home page and a nice quick guide .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM