Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
  HXTT Excel v6.1
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT Excel
question about firstRowHasNames
qorauskim
2017-11-07 00:55:10
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.
Re:question about firstRowHasNames
HXTT Support
2017-11-07 03:47:48
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?
Re:Re:question about firstRowHasNames
qorauskim
2017-11-07 18:02:57
you are right!! I tried with new downloaded trial version and I got the same result with you.
thank you.

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap