Is there any way to update excel content in background when the sheet is in open state.
I am using Apache POI Spreadsheet API (java based API) to read and write content in excel sheet.
By using user API, I am saving data to excel sheet, but I didn't find any API to update excel data in background(without closing excel file, content should be updated).
If we try to update excel when it's open it'll show error like file is accessed by other resource.
Please help me to find an API to achieve this by using Apache POI or any other API.
(I observed by using VB script we can achieve this. but first preference is Java, if there is no other API available then VB Script).
Excel puts a lock on the file and thus actively prevents other applications from changing the file, so I don't think this is possible with any library.
Related
I'm writing a portlet web app to allow user upload a excel file, and then the backend will do the validation to the excel file and convert the content into sql statement
The back-end is using java with library aspose.cells to handle the excel access.
The problem is, how can I pass the excel to back end to access.
Now I've think of after user upload the excel file, the back end first will download the excel file to local (maybe C:\temp), and then it can directly read the excel file from C:\temp rather than server file.
But it's possible to do it?
You seem to be looking for some sample code where you may upload an Excel file and then using Aspose.Cells for Java, process this uploaded file. You may have a look at the following link where a tutorial is there for uploading files using portlets.
http://www.codeyouneed.com/liferay-portlet-file-upload-tutorial/
Once the file is uploaded, use com.aspose.cells.Workbook class object for loading this stream directly into Workbook and then process it as per your requirement.
Following is the link to sample code for loading Excel file (in stream) into Workbook object:
https://docs.aspose.com/display/cellsjava/Opening+Files+with+Different+Formats#OpeningFileswithDifferentFormats-OpeningthroughStream
Note: I am working as Support developer/ Evangelist at Aspose.
I am using GWT with java. in my application i should upload excel file and should read the content of excel file and store data in entity. I have multiple columns in my excel sheet and i need to map them with my fields in the entity. please suggest me how to achieve this. for example : I have customer Names in excel sheet i need to save them in database/entity on click of button
any help.
For uploading a file you need a multipart upload form.GWT supports this with the FormPanel and the FileUpload widget.
If the server implementation is done in Java, you need an Servlet that handles the upload. Apache Commons Fileupload will help you handling the request.
As mentioned above Apache POI can help parsing the Excel document.
You can upload excel file as any file. The detailed gwt example you can find here
http://www.celinio.net/techblog/?p=1207
To read from excel you have to use Apache POI APIs for microsoft docs.
https://poi.apache.org/
You can use the following example to make yourself familiar with the excel api's
How to read and write excel file in java
HOw do we input data in excel sheet using java code , the excel sheet format is shown in the photo below.
The Total days and Hrs are calculated automatically here in sheet as soon as i enter in the above columns, Please tell me how do start . Also these input are associated to the other sheet(sheet2) . so please tell me the way so that it also flexible and i can modify the data in the sheet2.
![Excel sheet that needs to be automated][2]
Use a third party library like apache poi for reading Excel data in Java.
You might want to try the jexcelapi found on sourceforge: JExcelApi
Very easy to use to read & write excel files from java.
You use Java Excel API. This is an excellent article that demonstrates reading from and writing to Excel with Java.
Here is the Java Excel API download.
I am trying to make a program through which i want to manipulate data in the excel sheet,
But data is being manipulated only when the excel sheet is open.
whats the process to open and close it using java coding.
You can use POI to read and write Excel sheets.
This article is interesting to understand how to use it :
http://onjava.com/pub/a/onjava/2003/04/16/poi_excel.html
Hey look, there's a tutorial on how to do this link from the JExecel website!
http://www.andykhan.com/jexcelapi/tutorial.html
Side note: It looks like JExcel is file based only. This means you can't interact with an open spreadsheet. If you need to interact with an open spreadsheet you will have to use JNI or a library such as J-Integra COM, which uses JNI.
Here's the problem:
Run a java client as a batch job on a unix box which will connect to Oracle and fetch some data.
Update an excel sheet (on a Windows machine) with the data fetched.
Create a chart/graph from the data in excel sheet.
Send the excel (with data & graph) in an email.
All the above steps must be performed without any manual intervention.
Could there be a better option to excel based solution? The main intent is to have a history of data fetched and have a chart created from that data.
I know there are many open source libraries available for creating charts like JFreeChart, but is there anything in the JDK that allows you to create charts? Could JavaFX be used for this problem?
In short, is it possible to do this with just jdk (without using any open source libraries)?
Any help/suggestion will be appreciated.
You could try google docs spread sheet api to workaround MS-Excel
I think all that is pretty doable from Google docs, and yet, you still have the option of downloading the spread sheet.
From the link:
Spreadsheets Data API
The Spreadsheets Data API lets you access worksheet data within your own application or website. You can view and modify data, create and delete worksheets, issue structured queries, and more.
Spreadsheets Gadgets & Visualization API
Spreadsheets Gadgets take advantage of the Google Visualization API to embed graphical comparisons of of structured data within a spreadsheet.
Sounds like what you need.
Pretty straightforward, just use Hibernate or even jdbc.
You should be able to update the Excel sheet with Apache POI. You could also try Java Excel Designer or http://www.moyosoft.com/jec/
At least one of the above should be able to create charts.
Just use Java Mail
You could wrap the above in ANT tasks as appropriate.