这是我的代码。我想将Column6导出,并将其行导出到Excel工作表。我该怎么办?
Excel.Application excel = new Excel.Application();
excel.Visible = true;
object Missing = Type.Missing;
Workbook workbook = excel.Workbooks.Add(Missing);
Worksheet worksheet = (Worksheet)workbook.Sheets[1];
for (int i = 5; i < dataGridView6.Columns.Count; i++)
{
worksheet.Cells[1, 1] = dataGridView6.Columns[i].HeaderText;
}
for (int i = 0; i < dataGridView6.Rows.Count - 1; i++)
{
for (int j = 5; j < dataGridView6.Columns.Count - 1; j++)
{
worksheet.Cells[1, 1] = dataGridView6.Rows[i].Cells[j].Value.ToString();
}
}
}