0

I have to read all the cells of any column with header name "ABCD". I can get the values iterated over to any row but am stuck with a situation to get the column header name. I can also get the column header name using the excel as database: String sSQL = "Select * from [MAIN$]"; //sql statement Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DriverId=22;Dbq= " + XLSPath + ";ReadOnly=0;");
        Statement stmnt = conn.createStatement(); 
        rs = stmnt.executeQuery(sSQL);  //sql statement

        Statement stmnt1 = null;
        //Connection conn1 = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DriverId=22;DBQ= " + XLSPath + ";ReadOnly=false;");
        stmnt1 = conn.createStatement();
        stmnt1 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

String ctvstr = "Update [MAIN$] SET EXCEL_Heading=" + "'" + ColValues + "'" + " Where ID=" + j; stmnt1.executeUpdate(ctvstr);

I have to do the same thing in Java + xssf + poi

Kumar
  • 329
  • 2
  • 6

2 Answers2

0

I think you need ResultSetMetaData, ckeck this site http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html

Omar.Nassar
  • 379
  • 1
  • 3
  • 14
  • above link is very helpful, but isn't the scope of "resultSet" limited to windows only. – Kumar Jan 26 '15 at 17:29
0

To find the Column name and iterate over to the respective column with its header name for example "ABCD" , the solution to get this is to find the cell in first row with string matching "ABCD" and then iterate over to respective column(with the cell number of "ABCD")

Kumar
  • 329
  • 2
  • 6