经历过被人瞧不起就应该更努力,而不是放弃,要记住没有学不会的东西,放弃往往是最容易的
//创建list集合
List<Teacher> list = new List<Teacher>()
{
new Teacher(){Name="ww",Age=18,Sex="ss",Phone="ss"},
new Teacher(){Name="ss",Age=18,Sex="ss",Phone="ss"},
new Teacher(){Name="aa",Age=18,Sex="ss",Phone="ss"}
};
//创建workbook
IWorkbook wkbook = new HSSFWorkbook();
//创建sheet
ISheet sheet = wkbook.CreateSheet();
for (int i = 0; i < list.Count; i++)
{
IRow row = sheet.CreateRow(i);
row.CreateCell(0).SetCellValue(list[i].Name);
row.CreateCell(1).SetCellValue(list[i].Age);
row.CreateCell(2).SetCellValue(list[i].Sex);
row.CreateCell(3).SetCellValue(list[i].Phone);
}
//创建文件流
using(FileStream fs = File.OpenWrite("ss.xls")){
wkbook.Write(fs);
}
MessageBox.Show("导出成功");