• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading excel file

 
Sundar Gopal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me how to read an excel file stored in the client machine thru a servlet and populate the datas to the db .
 
din dee
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the coding abt to read excel sheet shell by sheel and and store the Database (oracle). using jsp,servlet,VO
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interpreting an EXCEL file in Java can be done with the HSSF toolkit from the Apache POI project.
Bill
 
Sundar Gopal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
thanks for your response. i used poi only to generate the excel file and i send it to client with a URL in it. the client after modifying the excel when he cliks the url has to update the modified data to the db. this is the scenario.
if i use HSSS i am not getting the values in the excel from the client side since i cannot load the file from the client and read it.
i am having a java class which reads the data good. but if i access the class via servlet its not working. my java class is like this........

package excel;

/**
* @author gsundar
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/


import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;

public class ExcelReaderClass{
public static void main( String [] args )
{
Connection c = null;
Statement stmnt = null;
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc dbc:Report_sheet");
stmnt = c.createStatement();

String table = "Report_Sheet$";

String query = "select * from" +"\"" + table + "\"";
ResultSet rs = stmnt.executeQuery(query);

System.out.println( "Found the following in the excel:" );
while( rs.next() )
{
System.out.print( rs.getString(1)+" " );
System.out.print( rs.getString(2)+" " );
System.out.print( rs.getString(3)+" " );
System.out.print( rs.getString(4)+" " );
}
}
catch( Exception e )
{
System.err.println( "Exception in class :"+e );
}
finally
{
try
{
stmnt.close();
c.close();
}
catch( Exception e )
{
System.err.println("Exception in connection close() :"+ e );
}
}
}
}
 
Sundar Gopal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but the above java class also works only if i configure datasource in my system for the excel file so that each worksheet will be like a table. this is not the solution i am searching for. i am in need of a better solution. your valueble inputs highly appreciated...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic