Program Will Not Read First Row in Excel Sheet
I am having difficulty getting my program to read the first row of my excel sheet. When I use the next() method the first time it automatically starts at the second row. Here is what I have for my method that reads the data from an excel file.
package excel;
import java.sql.*;
public class Excel
{
public void readexel(String filename) throws SQLException
{
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 [Sheet1$]" ;
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() )
{
System.out.print("Row #" + rs.getRow() + ": ");
System.out.print( rs.getInt(1) + " " );
System.out.print( rs.getInt(2) + " ");
System.out.println( rs.getInt(3) );
}
}
catch( Exception e )
{
System.err.println( e );
}
}

