Private void button#click (Object sender, eventargs E)
{
Try
{
String path;
Path = @ "D: \ succeccful.xls ";
Excel. Application xlapp;
Excel. Workbook xlbook;
Excel. worksheet xlsheet;
Xlapp = new excel. applicationclass ();
Xlbook = xlapp. workbooks. _ open (path, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value, missing. value );
Xlapp. displayalerts = false;
Xlapp. cells [2, 2] = "123 ";
MessageBox. Show (xlapp. cells [2, 2]). tostring ());
// The result of the above sentence shows system. _ comobject, which needs to be forcibly converted. For example, the following sentence
MessageBox. Show (Excel. Range) xlapp. cells [2, 2]). value2.tostring ());
Xlbook. saveas (path, missing. value, missing. value, missing. value, missing. value, missing. value, Excel. xlsaveasaccessmode. xlexclusive, missing. value, missing. value, missing. value, missing. value, missing. value );
Xlapp. Quit ();
Xlapp = NULL;
}
Catch (exception ex) {MessageBox. Show (ex. Message );}
}
**************************************** ********************
These are http://dotnet.wgets.com/thread/400640 found online
Forced conversion required
(Excel. Range) xlapp. cells [2, 2]). Text // (read-only)
(Excel. Range) xlapp. cells [2, 2]). Value // (read/write)
(Excel. Range) xlapp. cells [2, 2]). value2 // (read/write)
**************************************** ********************
Http://dotnet.wgets.com/thread/400640