Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.

I have small c# project.

I want to write some values in .xls file.
This is screen red ? is columns which I want to fill
Please tell me if it possible and if so please give some good tutorial
this is pic
http://img192.imageshack.us/img192/5402/37695348.jpg
Posted
Updated 21-Oct-10 5:03am
v2

This may Help[^]

C# Corner is also a useful developer site.
(Shouldn't say, very anti CP, but it is a specialist forum for c#.)
 
Share this answer
 
C#
public static void XLSWriter(string filename, string desiredcell, double number)
{
  try
  {
    string path = @"c:\Documents and Settings\rdockter\My Documents\" + file + "";
    string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=NO;READONLY=FALSE\"";
    OleDbConnection conn = new OleDbConnection(connectionstring);
    OleDbCommand command = new OleDbCommand();
    conn.Open();
    command.Connection = conn;
    string Sql = "UPDATE [Sheet1$" + desiredcell + ":" + desiredcell + "] SET F1='" + number + "';";
    command.CommandText = Sql;
    command.ExecuteNonQuery();
    conn.Close();
  }
  catch (OleDbException ex)
  {
    Console.WriteLine("Error: {0}", ex);
  }
}

Try using this little method.
 
Share this answer
 
v2
Comments
fjdiewornncalwe 30-Jun-11 22:45pm    
Just added pre tags to make the source more readable... Cheers.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900