Excel Script
Excel Script
HeaderText;
worksheet.Cells[4, i].EntireRow.Font.Bold = true;
}
// storing Each row and column value to excel sheet
for (int i = 0; i < DTGRIDVIEWEXCEL.Rows.Count; i++)
{
for (int j = 0; j < DTGRIDVIEWEXCEL.Columns.Count; j++)
{
if (tabControl1.SelectedTab == tabPage1)
{
worksheet.Cells[i + 5, j + 1] =
DTGRIDVIEWEXCEL.Rows[i].Cells[j].Value.ToString();
}
}
worksheet.Columns.AutoFit();
worksheet.Cells[1, 1].Borders.LineStyle =
Excel.XlLineStyle.xlContinuous;
SaveFileDialog1.ShowDialog();
try
{
workbook.SaveAs(SaveFileDialog1.FileName, Type.Missing,
Type.Missing, Type.Missing,
Type.Missing,
Type.Missing,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
this.Cursor = Cursors.Default;
app.Visible = true;
MessageBox.Show("Excel Export Successful");
}
catch (Exception)
{