Posted on: 8/29/2012 8:19:44 AM | Views : 681

Hello,
I created a method to export DataGrid to excel:
protected void ExcelBtn_Click(object sender, EventArgs e) { Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); ExcelApp.Application.Workbooks.Add(Type.Missing); // Change properties of the Workbook ExcelApp.Columns.ColumnWidth = 20; // Storing header part in Excel for (int i = 1; i < kwalDG.Columns.Count + 1; i++) { ExcelApp.Cells[1, i] = kwalDG.Columns[i - 1].HeaderText; } // Storing Each row and column value to excel sheet for (int i = 0; i < kwalDG.Rows.Count ; i++) { for (int j = 0; j < kwalDG.Columns.Count; j++) { string value = kwalDG.Rows[i].Cells[j].Text; ExcelApp.Cells[i + 2, j + 1] = value; } ExcelApp.A ...

Go to the complete details ...