jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes problem while reading data from excel sheet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem while reading data from excel sheet" Watch "problem while reading data from excel sheet" New topic

problem while reading data from excel sheet

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
when i try to read data from excel sheet, iam getting null values eventhough data exist in the excel sheet.
Can anyone tell me what could be the problem?

here is the code......
con1=DriverManager.getConnection("jdbcdbcRIVER={Microsoft Excel Driver (*.xls)};DBQ="+Path1+name1,user1,passwd1);

String query1="select * from "+tname;

while (rs1.next())
String str_value1=rs1.getString(1);
String str_value2=rs1.getString(2);
String str_value3=rs1.getString(3);
String str_value4=rs1.getString(4);
String str_value5=rs1.getString(5);
String str_value6=rs1.getString(6);
String str_value7=rs1.getString(7);
System.out.print(str_value1+" ");
System.out.print(str_value2+" ");
System.out.print(str_value3+" ");
System.out.print(str_value4+" ");
System.out.print(str_value5+" ");
System.out.print(str_value6+" ");
System.out.print(str_value7+" ");

catch(Exception e)

..........................end of code.........
Excel sheet contains numeric data and text data..
first row: 10 20 30 ab 30 and so on

while retrieving data iam getting data as null, for example in the above case instead of "ab" iam getting as null..
tell me how to sort this problem.

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Hi Abhishek

see below shown is the small code snippet which i have used to get data
from excel sheet ,the filename is the user choosen file name and it works as expected.............

i hope it helps you to some extent.

Dhwani:>Winning is not important but it is the only thing.
I agree. Here's the link: http://aspose.com/file-tools
subject: problem while reading data from excel sheet
It's not a secret anymore!