hi there. I have one question about firstRowHasNames.
(I use excel_jdbc30.jar)
please look at my example.
String url = "jdbc:excel:/F:/download/Forecast1.xls?firstRowHasNames=4";
Connection con = DriverManager.getConnection(url, "", "");
String sql = "select * from Sheet1";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int iNumCols = resultSetMetaData.getColumnCount();
Object colval;
while (rs.next()) {
for (int i = 1; i <= iNumCols; i++) {
colval = rs.getObject(i);
System.out.print(colval + " ");
}
System.out.println();
}
rs.close();
stmt.close();
con.close();
I use excel file like below :
Date:20170918
Author:Arnold
ASIN Brand ID type External ID Product group
B006MIUM20 Temparary UPC 841550050547 Furniture
B006MISZOC Temparary UPC 790725486417 Furniture
B00Q7EPSHI Temparary UPC 841550077209 Furniture
B00Q7EPV8O Temparary UPC 841550077216 Furniture
B01NH0XWNU Temparary UPC 841550097993 Furniture
please notice that actual column data starts at 4th.
so I use firstRowHasNames=4 at url string.
I guess I can get only data part with print-out statement like:
B006MIUM20 Temparary UPC 841550050547 Furniture
B006MISZOC Temparary UPC 790725486417 Furniture
B00Q7EPSHI Temparary UPC 841550077209 Furniture
B00Q7EPV8O Temparary UPC 841550077216 Furniture
B01NH0XWNU Temparary UPC 841550097993 Furniture
but I get :
Author:Arnold null null null null
null null null null null
ASIN Brand ID type External ID Product group
B006MIUM20 Temparary UPC 841550050547 Furniture
B006MISZOC Temparary UPC 790725486417 Furniture
B00Q7EPSHI Temparary UPC 841550077209 Furniture
B00Q7EPV8O Temparary UPC 841550077216 Furniture
B01NH0XWNU Temparary UPC 841550097993 Furniture
I try with firstRowHasNames=3 or =2 but I always get the result above.
and When I change my url to "jdbc:excel:/F:/download/Forecast1.xls?FirstRowHasNames=4"; (first F is upper char) I get the weird result:
Date:20170918 null null null null
Author:Arnold null null null null
null null null null null
ASIN Brand ID type External ID Product group
B006MIUM20 Temparary UPC 841550050547 Furniture
B006MISZOC Temparary UPC 790725486417 Furniture
B00Q7EPSHI Temparary UPC 841550077209 Furniture
B00Q7EPV8O Temparary UPC 841550077216 Furniture
B01NH0XWNU Temparary UPC 841550097993 Furniture
could you please explain about the actual action of "firstRowHasNames" with int number?
Thank you in advance.
|
In my test with firstRowHasNames=4 , it will show:
ASIN Brand ID type External ID Product group
B006MIUM20 Temparary UPC 841550050547 Furniture
B006MISZOC Temparary UPC 790725486417 Furniture
B00Q7EPSHI Temparary UPC 841550077209 Furniture
B00Q7EPV8O Temparary UPC 841550077216 Furniture
B01NH0XWNU Temparary UPC 841550097993 Furniture
The total row number of resultset: 5
So maybe you're using an older package?
|
you are right!! I tried with new downloaded trial version and I got the same result with you.
thank you.
|