I have an excel file that pulls in data via data connection from bunch of CSV files. The CSV files are generated every now so often by a JAVA program.
Is it possible to refresh the data too via. JAVA program? I see JXCELAPI and JOI are there, but briefly looking at their documentation doesn't indicate my use case is even possible.
In short, I need API that could achieve this effect: clicking on menu Data->Refresh All.
Thanks,
_Madhu
You could try XLLoop. This lets your spreadsheet talk directly to a java server (or a number of other languages) via function calls.
So you can have your spreadsheet call eg GetMyData("somedata") and it will load the data directly from your server whenever you re-calc (ie. Shift-F9).
BTW, I work on the project so let me know if you have any questions.
This tutorial sounds like it might help: Accessing Excel from Java
You could also try Obba which is another solution to access a Java library via Excel cell functions (UDFs)...
However, what you describe could also be done by a very small vb/vba macro which checks/polls for modification of these CVS files. I don't know if this is suitable in your situation, but there is an event listener for that: http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.changed.aspx#Y0
Related
I'm looking a way to take a string (for example from a cell in excel, but it does not have to be from excel) and paste it in a form in a web page.
I prefer to do it in java but I didn't find anywhere how it's can be done in java.
Which way it's can be done?
Thanks.
Shaked.
You could consider using Selenium. It lets you pre-define a set of actions for a browser, including going to a certain page, fiddling with form fields, and submitting the form.
It is possible to program this with Java, and as you may know, you can also use Java to read from files on your computer.
My work has tasked me with determining the feasibility of migrating our existing in-house built change management services(web based) to a Sharepoint solution. I've found everything to be easy except I've run into the issue that for each change management issue (several thousand) there may be any number of attachment files associated with them, called through javascript, that need to be downloaded and put into a document library.
(ex. ... onClick="DownloadAttachment(XXXXX,'ProjectID=YYYY');return false">Attachment... ).
To keep me from manually selecting them all I've been looking over posts of people wanting to do similar, and there seem to be many possible solutions, but they often seem more complicated than they need to be.
So I suppose in a nutshell I'm asking what would be the best way to approach this issue that yields some sort of desktop application or script that can interact with web pages and will let me select and organize all the attachments. (Making a purely web based app (php, javascript, rails, etc.) is not an option for me, so throwing that out there now).
Thanks in advance.
Given a document id and project id,
XXXXX and YYYY respectively in
your example, figure out the URL
from which the file contents can be
downloaded. You can observe a few
URL links in the browser and detect
the pattern which your web
application uses.
Use a tool like Selenium to get a
list of XXXXXs and YYYYs of
documents you need to download.
Write a bash script with wget to
download the files locally and put
in the correct folders.
This is a "one off" migration, right?
Get access to your in-house application's database, and create an SQL query which pulls out rows showing the attachment names (XXXXX?) and the issue/project (YYYY?), ex:
|file_id|issue_id|file_name |
| 5| 123|Feasibility Test.xls|
Analyze the DownloadAttachment method and figure out how it generates the URL that it calls for each download.
Start a script (personally I'd go for Python) that will do the migration work.
Program the script to connect and run the SQL query, or can read a CSV file you create manually from step #1.
Program the script to use the details to determine the target-filename and the URL to download from.
Program the script to download the file from the given URL, and place it on the hard drive with the proper name. (In Python, you might use urllib.)
Hopefully that will get you as far as a bunch of files categorized by "issue" like:
issue123/Feasibility Test.xls
issue123/Billing Invoice.doc
issue456/Feasibility Test.xls
Thank you everyone. I was able to get what I needed using htmlunit and java to traverse a report I made of all change items with attachments, go to each one, copy the source code, traverse that to find instances of the download method, and copy the unique IDs of each attachment and build an .xls of all items and their attachments.
In my java application I am connecting to Microsoft Excel with Jacob libraries. Everything is fine but I do not know how I can catch com events when any changes in Excel page occurs by using Jacob libraries. For example, In my project I connect database takes table values and copy these values into cells of an excel page. Whenever a cell value is changed, the table value is also changed. That's I want synchronization between java and Microsoft Excel application by Jacob.
Don't use Java to achieve that. See this question: Excel OnChange event, with emphasis on this answer. You should access your database using com directly from Excel. That's easy using ADO. This ADO tutorial from w3schools looks also fine.
If the task is too complex to perform directly from Excel you may think of putting a small marker somewhere (e.g. in the database) that the data changed and process this marker from other app, possibly java app. The difficulty is that the credentials to access the database must be hardcoded in the Excel sheet. But you can create a separate database user with narrow database permissions.
Seeing your comment I also tried using Change event of Excel to detect changes done by other users. My experience on Excel 2003 shows that this works only locally. That is the event is fired only for the user that made the change. If many users have the worksheet open they don't receive Change event caused by changes from other users. So your approach is unfeasible. You may test it with Excel 2010, but my impression is that the events in general work only locally. Couldn't find anything on the net about it. Only this general article: Track changes in a shared workbook.
I've created a pretty complex Google spreadsheet. I would like a user to be able to click a button or follow a link, and get a copy of this spreadsheet where they can fill in data. I would later check process this data manually.
Is there anyway I can do this via a complicated link, or some Javascript, or possibly even using a server side language (e.g. Python, Java).
Thank you,
You have a few options:
Rather than force a user to create a spreadsheet that you verify, you can email them a form to fill out with Google forms, and the answers get aggregated back on your spreadsheet.
Use the docs API to copy documents.
Use Google Apps Script to automate the process (it's essentially javascript).
Copying the document from the client side:
http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#CopyingDocs
Using the Java API, it would seem you'd have to export the document and then upload it:
http://code.google.com/apis/documents/docs/3.0/developers_guide_java.html
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.