cancel
Showing results for 
Search instead for 
Did you mean: 

values not getting inserted into excel sheet

Former Member
0 Kudos

The main purpose of the application that I am going to develop is

I created a form which consists of two input fields and a button using a tool by name NWDS which is made by adding some plugins to The ECLIPSE tool

Once the user enters the data in the input fields and clicks on the button the data must get inserted in the EXCEL sheet which is stored on my desktop

DETAILS OF EXCEL SHEET

Name: empdetails.xls

Fields : EmpID ,EmpName

Java code which I have written is

Here ACTION1 is the action created for the button

Here first I fetch the data in the inputfields using getEMPID() and getEMPNAME()

Then I tried to create a connection to access the excel sheet

Then wrote the insert query.

How I got the ExcelJDBCTest?

Click start-àSettingsàControlPanel

Double click on ODBC

Click on SystemDSN.

Click Add

In the installed ODBC Drivers list select MICROSOFT EXCEL DRIVER

Clik Ok

In the Data Source Name field spreadsheet alias (ExcelJDBCTest)

Click on Select Workbook

Select the Path and filename (empdetails.xls)

Click on OK

Click on Ok in the ODBC MicrosoftExcel setup window

Click close

public void onActionACTION1(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionACTION1(ServerEvent)

String eid = wdThis.wdGetContext().currentContextElement().getEMPID();

String ename = wdThis.wdGetContext().currentContextElement().getEMPNAME();

try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:ExcelJDBCTest");

String sqlstmt = "INSERT INTO values(?,?)";

PreparedStatement stmt = con.prepareStatement(sqlstmt);

stmt.setString(1,eid);

stmt.setString(2, ename);

stmt.executeUpdate();

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Once I execute the above code I do not see the values getting inserted into the excel sheet

Thanks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

As you are using jdbc-odbc bridge

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:ExcelJDBCTest");

Your DataSourceName "ExcelJDBCTest" should exists on the server where the webdypro app is deployed.

Regards

Ayyapparaj

Former Member
0 Kudos

Hi

Could you please provide me the steps how to create a DSN On the server....

I do have all rights to access the server

Forgot to tell you Microsoft excel and EP server are installed on the same machine

Thanks in advance