excel| data
. NET encapsulates Excel-related classes, the following are events triggered by clicking the Excel Output button in the program's winning toolbar, provided that you have Excel installed in your system.
Here is my code, with a note stating:
private void Toolbar1_buttonclick (object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{//toolbar button click event
if (e.button==excelout)
{
Excel.Application excelkccx = new Excel.Application ();//Create Excel Object
EXCELKCCX.WORKBOOKS.ADD (TRUE);//Create Excel workbook
DataTable mydatatable=mydataset.tables["Inventory information"];//create a datasheet that gets the data from the "Inventory information" table in the DataSet
int row=2;
Enter the data table's various information into the Excel table
for (int i=0;i<mydatatable.columns.count;i++)//Fetch field name
{
Excelkccx.cells[1,i+1]=mydatatable.columns[i]. Columnname.tostring ();
}
for (int i=0;i<mydatatable.rows.count;i++)//Fetch record value
{
for (int j=0;j<mydatatable.columns.count;j++)
{
EXCELKCCX.CELLS[ROW,J+1]=MYDATATABLE.ROWS[I][J]. ToString ();
}
row++;
}
excelkccx.visible=true;//make Excel Visible * *
}
else if (e.button==reportform)
{
Kcrptform myreport=new kcrptform ();
Myreport.mdiparent=this;
Myreport.show ();
}
Source: The movement of the BLOG