Sorting a Excel file using java
My Requirement is... I have a dataset(Excel) file residing in mainframe and I have to get the file, Sort the columns(more than one) and then place the file into different path.
All I need to know is How can I sort the columns in the excel file using Java.
Thanks in Advance
Basically, this is no easy task. I believe that you can use JDBC to connect to the Excel sheet. Create a User Data Source in the ODBC to point to the Excel Spreadsheet. You should be able to connect to the spreadsheet as you would a database. Keep in mind that the SQL Query will be a little different as (I beleive) that you have to enter the worksheet name in square braces ( i.e. [Sheet1]ColumnName ) but check on this before trying.
Also keep in mind that since you are trying to link a Java program to an Excel spreadsheet, and Excel has no direct support for Java, that there will probably be some rather interesting problems along the way.
But have a look for JDBC and Excel on a search engine, and this should get you started.
You can also read in the excel file through the jexcel api (http://www.andykhan.com/jexcelapi/)
once you can read in the entire excel file into java, you can create your own Java object structure and go from there.
To my knowledge the most popular API for manipulating Excel files is Apache POI (http://jakarta.apache.org/poi). This is an API for reading office-documents in general. For reading Excel there is the hssf subproject (http://jakarta.apache.org/poi/hssf). They also have a list of alternative projects that can be used for accessing Excel files (http://jakarta.apache.org/poi/hssf/alternatives.html)
And for yet another solution, you could use the copy/paste java api and copy the
excel buffer directly into your app,... no a very dynamic solution but it works.
Then of course there is the neanderthal method of saving the excel as a
tab-delimited text file
Using a Java-COM Bridge like J-Integra for COM, you can easily access/modify MS Excel from Java client. You can find more information about it at http://j-integra.intrinsyc.com
J-Integra for COM's pure Java runtime talks to COM components using Distributed COM (DCOM) layered over Remote Procedure Calls (RPC). The RPCs are themselves layered on TCP/IP. Therefore, at the lowest level, J-Integra for COM uses standard Java networking classes.
Here's an very simple example to show you how easy to access Excel from Java client:
J-Integra Interoperability Solutions
high performance interop middleware for java, corba, com & .net
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center