This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem while reading data from excel sheet  RSS feed

Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!