回复 楼主 tankin
希望大虾们帮帮忙
Excel.Application app = new Excel.ApplicationClass(); app.Workbooks.Add(true); int idx = 1; for (int i = 0; i < dgvMain.Columns.Count; i++) { if (!dgvMain.Columns[i].Visible) continue; app.Cells[1, idx++] = dgvMain.Columns[i].HeaderText; } idx = 1; for (int i = 0; i < dgvMain.Columns.Count; i++) { if (!dgvMain.Columns[i].Visible) continue; for (int j = 0; j < dgvMain.Rows.Count; j++) { app.Cells[j + 2, idx] = dgvMain.Rows[j].Cells[i].Value; } idx++; } app.Visible = true;其中 dgvMain 是一个 dataGridView