Read from "non existing" (In disk) Excel with Java POI? - java

I have a (third party) software that loads data dinamically to an Open Excel (Via Visual Basic, I believe, but I am not sure), this excel is not saved until it is complete.
On the other side, I have a Java GUI that must read data on real-time from that Excel and show it to the user.
Is there a way to do this using POI? I already have all the algorithms and GUI ready, but third party software just changed the way it works and I need to change this.
TL:DR: I need to read from an excel that is currently open (Exists in RAM), but is still not saved into disk, is it possible?
Thank you all for your answers.

After working with Apache POI for some time, I can confirm:
This is impossible.

Related

What to use : Excel VS MySql/MongoDB [Java]

I am going to make a business application for my father to make GST(Goods and Services Tax) filing easier. I have the design ready and I am going to use JavaFX.
The user will enter the data in tableview and that data needs to be stored for future reference.
The tableview needs to be converted to an excel file (gonna use Apache POI). The excel file will be sent to a C.A who will file GST on my father's behalf.
The application will need to import/export data into/from the tableview and edit the data as necessary.
I have 2 options :
Store/retrieve data from MySQL to tableview, update it according to the user's will and later export the data into excel files for sending it to C.A.
Store/retrieve data from excel files to tableview, update it according to the user's will and send the excel file to C.A.
I am planning to expand the application into a complete Business software that can manage entire business.
What should I use?
Which one will be more efficient and why?
I hope I am able to convey my question (I ain't good at writing).
In my own opinion it is more efficient and have more posibilities to explotes the data using MySQL, because reading and writing an Excel file will take a lot of time and it is slower.
I'll answer my own question, since I have got the answer.
I'm going with SQLite for now as using csv or excel files is gonna consume a lot of resources (I tried it).
I am going to sync the .db file in drive using scripts from the application itself. MySQL is definitely better choice but I want to database to be used by 2 computers at a time (not in network) so I will have to pay for online database.
I will store the .db file and drive and will retrieve it whenever the application runs. In this way its going to be safe.

How do I edit Excel Spreadsheet shared over sharepoint.com using java

At my work I have a to keep records of all the supports I have provided to the clients of our company in an Online Excel sheet. Now being a java developer I find this very boring task and it also consumes my time as same data I have to copy paste 2-3 places. Can someone please tell how can I automate this using java.
Attached is the snapshot of my online excel sheet., we call it support tracker.
Under Support_Tracker we have to maintain all the supports we have provided to every project.
Then right to that(SalesForce_issue_tracer, Servicenow_issue_tracker) are the products for which we provide support. Now to these products sheet, I have to copy paste the data from Support_Tracker. I want to automate all this stuuf.
Please tell how can I achieve this.
I google it and found some APIs, one of them is Apache POI, but I am not sure whether I can edit an Online Excel fine using this.
Excel fine is on sharePoint.com.

Adding data in Excel file without closing it

I am currently using Apache POI to enter data into Excel file. The only problem is I can not keep the file open if I have to append data to the same file. Are there any specific sample codes which would allow me to do so?
My basic requirement is to fetch Runtime data from a place (this I am able to do) and add it to the Excel sheet while the file is still open.
Any suggestions?
I don't think that this is possible without a C# addon or some kind of macro. You could write a simple C# addon for Excel that connects to your java programm and recieves the realtime data. The addon will write it to the spreadsheat then.

Convert individual POI SS Sheets to byte[] - Java

I am developing an internal system that is intended to work very much like Google Docs. The main piece I am implementing mimics their web-based Spreadsheet implementation. For multiple reasons I am not able to use Google Docs or ZK, which has a very robust Spreadsheet API. I chose POI 3.7 as a starting point for my Excel spreadsheet processing.
Currently when a user uploads an Excel spreadsheet, I take the file byte[] and store it in our db as a blob. When a user wants to view the spreadsheet, I pull out the byte[], build the Workbook, and push it to the client UI for editing. The pushing to the UI isn't my concern. When a user makes edits to the spreadsheet, I push the edits to the server and store them on a stack and only apply the updates when the user presses the "save" button. On save, I pull the workbook back out of the database, make the changes and push the Workbook back to the db. That way, I don't keep it in memory. It's no surprise that all of this is pretty fast except for when multiple users start doing this, obviously exploding Workbooks eats memory as described in other posts here.
A user will only update one tab at a time, why should I need to open the entire workbook? When a user initially uploads an excel spreadsheet, can I pull out each Sheet, convert each to a byte[] and save each as an indiviaual "worksheet" db record? The POI Sheet has a protected, "#write(Stream)" method but I would not like to get into the business of re-compiling POI. I also would not like to explode every cell as a new db entry. Would you guys do this differently in the first place?
Backend is java/spring/jdbc. For internal reasons, these are the technologies I'm stuck using.
Storing big binary blobs in the database is in itself not a good thing if performance is important. You would be much better off storing the workbooks on the disk.
I can only give you half an answer to your question and that is that you can read xslx (not xsl) files one sheet at a time using (http://poi.apache.org/apidocs/index.html?org/apache/poi/xssf/eventusermodel/XSSFReader.html) and that you can use a SAXParser to avoid holding each full sheet in memory. I don't think there is any way of saving it without creating a sheet object.
Warning Hack: One quick hack could be to use reflection to call the protected method. There is of course no guarantee that this will work in future versions of POI.
With Excel files, some things are stored at the sheet level, but other bits are stored at the workbook level. As your user edits a sheet, while most of their changes will be on the sheet part, some bits will need to touch the workbook level entities, and for that you'll need the whole file.
You might want to take a look at how SharePoint does its collaborative editing, which allows several people using Excel to work on the same file much like google docs. All the SharePoint protocol documents are publicly available, and there was an event on the docs very recently for which videos and presentations should be online soon, keep an eye on the office interop blog for when they do. In the SharePoint docs you should find the details on how Microsoft chunks up an Excel file for collaborative editing, and there's something to be said for you doing the same!
I would consider looking into saving the sheets as separate XML's in the database. If you store additional (meta)data about sheets belonging together in the database it shouldn't be too much hassle keeping them together. The reason behind using XML is that from Excel 2003 up spreadsheets can be saved as xml and therefor can easily be created by code as well.
If at one point you seem to be hitting too many walls with Apache POI, you could look into the OpenOffice API as well.

DataGrid In Java Struts Web Application

After scouring the web I have edited my question from the one below to what it is now.
Ok I seem to understand that I don't need all the capabilities of excel right now. I think i am satisfied having a data grid to display data. Basically i am working on Struts 2 and I wat my jsp page to have an excel like feel and hence looks like even a datagrid is sufficient. I came across This Technology
I am not sure whether I must go ahead and use it. Any other suggestions, alternatives are welcome
The older version of the question
"I have a java web application running on windows currently. I may host it in future in a Linux Server.
My application allows people to upload data. I want to display the data they have uploaded in an excel file and render it in a portion of my webpage.
How do I go about this ?"
Basically you would need to read the excel files, get the data in some kind of java objects, and then show it back to user as a normal HTML page with tables etc..
If you want to show the excel files in such a way that your users are also able to edit these then you need to look into javascript / ajax to make a UI as per your needs.
An easy and open source way of reading the uploaded excel files in java is via Apache POI. It is capable of reading .xls files as well as the newer OOXML .xlsx files.
http://poi.apache.org/spreadsheet/
They have very helpful examples which can get you started within 10 minutes..
http://poi.apache.org/spreadsheet/quick-guide.html
If you can allow data to go to another site, then you can use ZOHO. Their online Excel Editing is reasonably good and you don't really have to do anything much.
Maybe you can try http://www.jxcell.net:
It is a java spreadsheet component which allow you to edit your Excel via web page.

Categories