DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Posts
    2

    Question Sorting a Excel file using java

    Hi,

    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
    Kandan.

  2. #2
    Join Date
    Feb 2004
    Posts
    31
    Hi Kandan,

    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.

    Cheers,

    James D.

  3. #3
    Join Date
    Oct 2004
    Posts
    311
    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.

  4. #4
    Join Date
    May 2005
    Location
    Bruges
    Posts
    1

    Hello

    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)

    Good luck

    Steven

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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
    eschew obfuscation

  6. #6
    Join Date
    Nov 2005
    Posts
    1
    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:
    http://j-integra.intrinsyc.com/suppo...l_example.html

    Cheers,

    Hao Zhang

    J-Integra Interoperability Solutions
    http://j-integra.intrinsyc.com/
    high performance interop middleware for java, corba, com & .net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links