aspose file tools*
The moose likes JDBC and the fly likes Writing values to Excel from Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Writing values to Excel from Applet" Watch "Writing values to Excel from Applet" New topic
Author

Writing values to Excel from Applet

Manikandan Kasirajan
Greenhorn

Joined: Jul 07, 2003
Posts: 4
Hi All Pls help me i dont know what is wrong i am coding as below for testing the connection between applet and excel,i get error while making the dsn connection that is in DriverManager.getConnection("jdbc dbc:Excel Files"); as below.
java.sql.SQLException: No data found
Excel Files dsn is default user dsn in odbc for Excel. i even tried by making a new system dsn and user dsn even then i get the same error can any one guide me. pls it is urgent.......
I want to write the data to excel from Applet
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");
System.out.println(" "+Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"));
conn=DriverManager.getConnection("jdbc dbc:Excel Files");
stmt=conn.createStatement();
//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){}
}
}
}


Warm Regards<br />Mani
Manikandan Kasirajan
Greenhorn

Joined: Jul 07, 2003
Posts: 4
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
 
jQuery in Action, 2nd edition
 
subject: Writing values to Excel from Applet