Forums Register Login

JSP

+Pie Number of slices to send: Send
[size=12]hai friends,
I am doing the program for reading the data from excel.
import java.io.*;
import java.sql.*;
public class ExcelReadTest{
public static void main(String[] args){
Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbc:odbc:emp" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );

ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();

while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue);
}
System.out.println("");
}

st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}
[/size]

in the above works well to retrieve the data from excel. But i want to select particular cell value.. i.e i want to select the column heading from excel.

guide me friends..
+Pie Number of slices to send: Send
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


Reply locked
This thread has been viewed 982 times.
Similar Threads
The specified DSN contains an architecture mismatch between the Driver and Application
How to insert data into excel file using java code?
Reading an Excel file using Java
Calling the Excel file using Java
Readin excel files from Java & output
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:07:11.