Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v6.0
  HXTT Cobol v3.0
  HXTT DBF v6.0
  HXTT Excel v5.0
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Paradox v6.0
  HXTT Text(CSV) v6.0
  HXTT XML v2.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 Beijing City (abbr, HXTT)

HXTT Excel
question about firstRowHasNames
qorauskim
2017-11-07 00:55:10.0
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.0
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.0
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 © 1999-2017 Heng Xing Tian Tai Lab of Beijing City. | All Rights Reserved. | Privacy | Legal | Sitemap