I am working on a school project and im using microsoft visual studio 2010 language c# (I have teached only C and a little bit of C++). I am making an Excel file. I'm using something like "add reference", .COM and add library from excel.
I can make a page some text in row and col now.
When I push button1_Click
, it opens my Excel file, and shows me the string "date"
on location [1,2]. For my button2_click
he is showing me my DateTime.Now
(MessageBox...)
Short code version:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//public string ReturnValue1 { get; set; }
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
....stuff
oSheet.Cells[1, 2] = "Date";
....
//now i want is oSheet.Cells[2, 2] = .//that shows me the actual date
}
public void button2_Click(object sender, EventArgs e)
{
DateTime theDate; //variabele theDate
theDate = DateTime.Now; // Date + time
MessageBox.Show(theDate.ToString(" dd-MM-yyyy")); //only date
}
}
}
Any idea how to deal with it (to send my DATE to print it in Excel) if it is possible?