{
{
Microsoft
.Office.Interop.Excel.ApplicationClass excel
= new Microsoft
.Office.Interop.Excel.ApplicationClass();
excel
.Application.Workbooks.Add(true);
DataSet ds
= new DataSet
(); System.Data.DataTable table = ds.Tables[0];
foreach (System.Data.DataColumn col
in table
.Columns) {
ColumnIndex++;
excel.Cells[1, ColumnIndex] = col.ColumnName;
}
{
rowIndex++;
ColumnIndex
= 0; foreach (DataColumn col
in table
.Columns) {
ColumnIndex++;
excel.Cells[rowIndex + 1, ColumnIndex] = row[col.ColumnName];
}
}
Microsoft.Office.Interop.Excel._Worksheet worksheet = (Microsoft.Office.Interop.Excel._Worksheet)excel.ActiveSheet;
//worksheet.Activate();
worksheet.Activate();
[COLOR="Red"]//Mình cần save lại với đường dẫn D:\Dulieu.xls là được rồi
//Không cần phải mở Excel lên[/COLOR]
}
{
// catch an xmlexception errors
MessageBox.Show(exml.Message, "Export Active Asset List", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}