Формат типа дата, текст, число при экспорте excel в datagridview C#
Please help me: I can't format Date (dd/mm/yyyy), Text, Number of Columns in Datagridview C# when Export Excel.
private void btnExportExcel_Click(object sender, EventArgs e)
{
if (dgvGF1111.Rows.Count > 0)
{
Microsoft.Office.Interop.Excel.Application xcelApp = new Microsoft.Office.Interop.Excel.Application();
xcelApp.Application.Workbooks.Add(Type.Missing);
for (int i = 1; i < dgvGF1111.Columns.Count + 1; i++)
{
xcelApp.Cells[1, i] = dgvGF1111.Columns[i - 1].HeaderText;
}
for (int i = 0; i < dgvGF1111.Rows.Count; i++)
{
for (int j = 0; j < dgvGF1111.Columns.Count; j++)
{
if (i < dgvGF1111.Rows.Count)
{
xcelApp.Cells[i + 2, j + 1] = dgvGF1111.Rows[i].Cells[j].Value.ToString();
//xcelApp.Cells[i+2, 3] = Convert.ToDateTime(dgvGF1111.Rows[2].Cells[3].Value);
}
}
}
xcelApp.Columns.AutoFit();
xcelApp.Visible = true;
}
}
What I have tried:
Format Date, Text, number,.... when Export Excel in Datagridview C#