import java.sql.*;
public class excelWrite
{
public static void main(String args[]) {
Connection conn=null;
Statement stmt=null;
String sql="";
ResultSet rs=null;
String srno="10";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
System.out.println(" "+Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"));
conn=DriverManager.getConnection("jdbc
dbc:Excel Files","","");
stmt=conn.createStatement();
sql = "CREATE TABLE [Sheet1$] (srno TEXT,test TEXT,description TEXT,output TEXT,output1 TEXT,pass TEXT)";
boolean b=stmt.execute(sql);
sql="INSERT INTO [Sheet1$](srno,test,description,output,output1,pass) VALUES ('1','Hari','Venke','Vasan','Swami','Shalin')";
int i =stmt.executeUpdate(sql);
}
catch (Exception e){
System.err.println(e);
}
finally {
try{
// rs.close();
// stmt.close();
//conn.close();
rs=null;
stmt=null;
conn=null;
}
catch(Exception e){}
}
}
}
this code works fine and inserts data into the excel file but it happens only when the USER DSN is assigned to a excel sheet and when it is open.
My program is a client server program,And user is just a lay man and he can not set the odbc settings for excelsheet,Is there any method where i can make it happen dynamically like open a excel file from applet and write the values to the spread sheet.
Pls help