<summary>
Writes the specified string to the specified cell
</summary>
<param name= "Data" > DataSource to write </param>
<param name= "SheetName" > Sheet name (full path +excel table name) </param>
<param name= "Row" > The first few lines </param>
<param name= "column" > Columns </param>
public void WriteData (string data,string sheetname, int row, int column)
{
Try
{
Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application ();//Instantiate an Excel object
Object missing = system.reflection.missing.value;//Gets the missing object type value
Open the specified Excel file
Excel. Application.DisplayAlerts = false;//does not display a prompt dialog box
Microsoft.Office.Interop.Excel.Workbook Workbook = Excel. Workbooks.Open (SheetName,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);//Open Excel
Microsoft.Office.Interop.Excel.Sheets Sheets = workbook. worksheets;//instance Table
Microsoft.Office.Interop.Excel.Worksheet Worksheet = (Microsoft.Office.Interop.Excel.Worksheet) sheets[1];//first table
Worksheet. Cells[row,column].value = data;
Workbook. Save ();//Saving worksheet
Workbook. Close (false, missing, missing);//Close sheet
}
catch (Exception e)
{
MessageBox.Show (E.message.tostring ());
}
}
C # Modifies the value of an Excel-specified cell