GeSHi (java):
import java.sql.*;
public class ExcelODBC {
public static void main
(String[] args
) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
ResultSet rs = st.
executeQuery("Select * from [Sheet1$]");
int numberOfColumns = rsmd.getColumnCount();
while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1)
String columnValue = rs.
getString(i
);
System.
out.
print(columnValue
);
}
}
st.close();
con.close();
System.
err.
print("Exception: ");
System.
err.
println(ex.
getMessage());
}
}
}
Created by GeSHI 1.0.7.20
This part of the code allows you to query the excel spreadsheet with SQL. This is a simple SQL query to select everything from Sheet1 in the spreadsheet.
GeSHi (java):
ResultSet rs = st.
executeQuery("Select * from [Sheet1$]");
Created by GeSHI 1.0.7.20