how to update a perticular cell in a Excel file?

liunx

Guest
hai every one,

how to update a perticular cell with in a Excel File ??

i was trying to find some code so that i can manupulat a excel file from a

webform in ASP.net ......and i even found a code..to do so in the following

section i am placing that snippet of code which is intended to show a Excel file

data in a DataGrid.....
-----------------------------------------------------
code....to fill datagrid using Excel data
-----------------------------------------------------
string tempstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\A.xls;Extended

Properties=Excel 4.0";

OleDbConnection con=new OleDbConnection(tempstr);

OleDbDataAdapter da=new OleDbDataAdapter("SELECT * FROM [A$]",con);

DataSet ds=new DataSet();
da.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();

-----------------------------------------------------------


this code is ok and working properly but i am facing problem while trying to

update some data in the file .........

for this iam using the following code.......
------------------------------------------------------
code....to update a cell inside a Excel spreadsheet......
==============================================================


string tempstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\A.xls;Extended

Properties=Excel 4.0";
OleDbConnection con=new OleDbConnection(tempstr);

OleDbCommand com=new OleDbCommand();
com.CommandText="UPDATE [A$B7:B7] SET F1 = '1'";
com.Connection=con;
con.Open();
com.ExecuteNonQuery();
con.Close();
========================================================================


i really donot know what is happening in line....

com.CommandText="UPDATE [A$B7:B7] SET F1 = '1'";

i hope it is a attempt to B7 so what is F1 out here .....i got this code on net
i will be really thank full if any one is able to explain the the code to me...


but this is giving the following error...... at line com.ExecuteNonQuery();

ERROR:
============================================================================
No value given for one or more required parameters.
Description: An unhandled exception occurred during the execution of the current

web request. Please review the stack trace for more information about the error

and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: No value given for one or

more required parameters.

Source Error:

com.ExecuteNonQuery();



=============================================================================


so can any one tell me how to update a perticular cell with in a Excel File ??

and with this in this this connection is ment for Excel 4.0 but what is to be

replaced in the connection parameters if i am using Excel 2000.......?

tanks to showing patience to read this mail......
and thanks in advance ....for the help

keep smiling....

austin neelankavil
 
Back
Top