java to excel connectivity



Share on Google+Share on Google+

java to excel connectivity
1 Answer(s)      7 years ago
Posted in : Swing AWT
give me source code to stored the value entered by user in a text field(such as name, age, sex, add. of the user etc.) that are on the jpanel to the database created in MSEXCEL 2007. actually i am making project on bank and i want to stored the information of customer to my database on the excel.
View Answers

July 23, 2010 at 1:23 PM

Hi Friend,

Follow these steps:

1. Open Data Sources (Start->Settings->Control Panel->Administrative Tool->Data Sources(ODBC)

2. Open User DSN tab
3. Add a user DSN
4. Select Microsoft Excel Driver(*.xls)
5. Select work book or excel file and Create the DSN name (e.g excel)
6. Click "Ok" and restart your compiler.
7. Compile the following java code:

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;

class InsertToExcelDatabase extends JFrame {
JButton ADD;
JPanel panel;
JFrame f;

JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
text1 = new JTextField(20);

label2 = new JLabel();
text2 = new JTextField(20);

ADD=new JButton("Insert");
ADD.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String v1=text1.getText();
String v2=text2.getText();
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
Connection c = DriverManager.getConnection( "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:/database.xls; readOnly= false");
Statement stmnt = c.createStatement();
String insertSql = "Insert into [Excel Sheet$] (Name,Address) values ('"+v1+"', '"+v2+"')";
int insertSuccess = stmnt.executeUpdate(insertSql);
catch(Exception ex){}
f=new JFrame();
panel=new JPanel(new GridLayout(3,2));
public static void main(String[]args){
InsertToExcelDatabase ff=new InsertToExcelDatabase();



Related Tutorials/Questions & Answers:
java to excel connectivity - Swing AWT
java to excel connectivity  give me source code to stored the value... excel) 6. Click "Ok" and restart your compiler. 7. Compile the following java... database on the excel.  Hi Friend, Follow these steps: 1. Open Data
Java connectivity with MySQL
Java connectivity with MySQL  Java connectivity with MySQL
java connectivity
java connectivity  hi........ Can u help me to do connectivity between java and weka??????? weka is a data mining tool which allows to do prediction, classification etc.... i want to do connectivity between weka and java can u
JAVA EXCEL  How to read the contents of an excel, perform some calculation and wrote the calculated values to another excel using poi
JAVA_EXCEL  I need to read the all the contents of excel which has... content another excel. For example if I have three tabs in an excel with some contents. The contents from all the three tabs has to be read by java program and has
java connectivity
java connectivity  i am trying to add dyanamic rows in the jsp page, when i add the new row the dropdown control value is not coming from database..please help me to overcome this problem
sql connectivity through java
sql connectivity through java  i want an example for java db through sql connection. Thanks in advance
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void... with sql server connectivity at the background to save the data. Now, after... the connectivity wrong. Kindly help me resolve this issue ASAP. Thank you
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
database connectivity in java - JDBC
database connectivity in java  import*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; class Project implements ActionListener { JFrame f; JPanel p1,p2,p3; JTabbedPane
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
Java database connectivity
Java database connectivity  Hi sir I need a code to create an application where user enter name in text box and that should be stored in database. Plz help me out its very urgent.   import java.sql.*; import java.awt.
Excel file Handling in Java
Excel file Handling in Java  Hello Sir, I am new to Java, I have Started Java Core by myself. I want to make a project which include 3-4 Excel file...://   Now to create an excel file
reading excel sheet in java
reading excel sheet in java  can anyone tell me a proper java code to read excel sheet using poi   Here is a java code that reads an excel file using POI api and display the data on the console. import
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
To read a excel with chart - Java Beginners
To read a excel with chart   Hi, I need to read the data in an excel which is in chart format using java. when I directly change the extention of excel file to CSV i am not getting the data in the chart.Please help me
DataBase connectivity in java with Microsoft sql server2000 - JDBC
DataBase connectivity in java with Microsoft sql server2000  How i can achieve database connectivity with Microsoft sql server2000 in my java source code
export java to excel - Java Beginners
export java to excel  How do you export java to excel?  You mean to say accessing Microsoft files in java? Then you can go for Apache POI. Its an API to access MS-Office files.Try using it. - Ramesh A.V
Java and excel - JDBC
Java and excel  i want to retrive records from my database to a Jtable from where i can export to excel, i will like to format the column headers in excel using code. plz i nd help becos it is my project, as a serious student i
excel file using JDBC java.?
excel file using JDBC java.?  hey, i am a telecomm. engineer , and i am try to develop a tool which reads from a excel file and then appends the same excel file as required. i am writing my code on notepad and have successfully
Excel file wriring using java
Excel file wriring using java  i have one predefined bill format in excel i want to append values in it using java apche POI or Jexcel i tried it but it overwrites file and lost previous contents what can i do
ODCB-EXCEL - Java Beginners
ODCB-EXCEL  Hi, i would like to extract data from an excel file. my excel file name is: TEST.xls the worksheet name is : qas i have configure...: "java.sql.SQLException: [Microsoft][Pilote ODBC Excel] Not enough parameters 1
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
Create SpreadSheet same as excel using java applet
Create SpreadSheet same as excel using java applet  Hi Ji, May i know to create new excel sheet using java Applet
connectivity  how to connect java with database
Creating Excel sheets - Java Beginners
Creating Excel sheets  Hi, I want the java code for creating excels sheets with two workbooks using POI, and to find the difference between the particular value of one cell and others. asuming the contents of teh files adn
Java vs Oracle Connectivity - JDBC
Java vs Oracle Connectivity  Write a java program to establish connection with oracle database?  Hi Friend, Use Oracle with Java Follow these steps: 1) Import the following packages in your java file
read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : Thanks
Excel conversion tool. - Java Beginners
Excel conversion tool.  Hi, I need a conversion tool which can convert .xls(Excel 2003) to .xlsx (Excel 2007) and vice-versa. Please suggest any links ro tools. Thank You
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program