This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Excel file manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Excel file manipulation" Watch "Excel file manipulation" New topic
Author

Excel file manipulation

Kums Vijayan
Greenhorn

Joined: Jan 25, 2010
Posts: 11
How to read and write from a excel file?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
See http://faq.javaranch.com/java/AccessingFileFormats for multiple solutions; Apache POI and jExcelApi being the most prominent.


Ping & DNS - my free Android networking tools app
Kums Vijayan
Greenhorn

Joined: Jan 25, 2010
Posts: 11
Thanks for the information...I tried using ODBC.But i encountered a error.

>java ExcelReader

java.sql.SQLException: [Microsoft][ODBC Excel Driver] Too few parameters. Expect
ed 3.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
Using ODBC with Excel has numerous problems; try one of the other options.

If you're set on using ODBC, however, then you'll need to show us the code that causes the exception, along with any runtime parameter values you may be using.
Kums Vijayan
Greenhorn

Joined: Jan 25, 2010
Posts: 11
This is the code
book is the name of the Excel Driver configured in Data sources present under administrative tools in control panel

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
public class ExcelReader
{
public static void main( String [] args )
{
Connection c = null;
Statement stmnt = null;
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection("jdbc:odbc:book",null,null);
stmnt = c.createStatement();
String query = "select URL from [Sheet1$] where Month='March' and Year=2000;";
ResultSet rs = stmnt.executeQuery( query );

System.out.println( "Found the following URLs for March 2000:" );
while( rs.next() )
{
System.out.println( rs.getString( "URL" ) );
}
}
catch( SQLException e )
{
System.err.println( e );
}
finally
{
try
{
stmnt.close();
c.close();
}
catch( Exception e )
{
System.err.println( e );
}
}
}
}
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Please go back to your post an edit it to add Code tags, so it will be easier to read.
Not a "beginning" topic: moving thread.
Kums Vijayan
Greenhorn

Joined: Jan 25, 2010
Posts: 11
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Excel file manipulation
 
Similar Threads
Jsp to Excel
Most portable format for data
Record Export?
Automate Excel Loading into Database
Exporting data to excel file... using java web app