0
데이터를 내보낼 때 Excel 파일이 비어 있습니다! 초보자이며 문제를 해결할 수 없습니다.C#에서 Excel 데이터 내보내기 앱
Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application();
Workbook wb = Excel.Workbooks.Add(XlSheetType.xlWorksheet);
Worksheet ws = (Worksheet)Excel.ActiveSheet;
Excel.Visible = true;
ws.Cells[1, 1] = "Row";
ws.Cells[1, 2] = "نام";
ws.Cells[1, 3] = "نام خانوادگی";
ws.Cells[1, 4] = "تاریخ ورود";
ws.Cells[1, 5] = "تاریخ خروج";
ws.Cells[1, 6] = "زمان ورود";
ws.Cells[1, 7] = "زمان خروج";
ws.Cells[1, 8] = "تاریخ فارسی";
for(int j=2;j<=dataGridView1.Rows.Count; j++)
{
for(int i=2;i<=5;i++)
{
ws.Cells[j, 1] = dataGridView1.Rows[j - 2].Cells[i - 1].Value;
}
}
워크 시트를 저장하고 닫는 코드가 누락되었습니다. –
이것 좀보세요 : http://stackoverflow.com/questions/6840099/how-can-i-export-data-to-excel-file –