This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Excel file manipulation  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to read and write from a excel file?
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://faq.javaranch.com/java/AccessingFileFormats for multiple solutions; Apache POI and jExcelApi being the most prominent.
 
Kums Vijayan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 );
}
}
}
}
 
Marshal
Posts: 61712
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!