Hi,
I am getting errors while reading values from a Excel file from webdynpro.
Below is the code :
public void onActionreadExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionreadExcel(ServerEvent)
String filename=wdContext.currentContextElement().getFileName();
//String filename= "c:
Excel.xls";
wdComponentAPI.getMessageManager().reportSuccess(filename);
Connection c = null;
Statement stmnt = null;
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=" + filename);
stmnt = c.createStatement();
String query = "Select * from [a$]" ;
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() )
{
wdComponentAPI.getMessageManager().reportSuccess(rs.getString("Product Code"));
}
}
catch( Exception e ) {
wdComponentAPI.getMessageManager().reportSuccess(e.toString()+"");
}
//@@end
}
I get following error.
java.sql.SQLException: [Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
Is thsi whole method of reading the excel file from webdynpro is wrong ?
Please help.
Thanks,
Regards,
Aditya