首页 > 其他 > 详细

NOPI导入到excel

时间:2017-08-22 15:07:35      阅读:303      评论:0      收藏:0      [点我收藏+]

经历过被人瞧不起就应该更努力,而不是放弃,要记住没有学不会的东西,放弃往往是最容易的

//创建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("导出成功");

NOPI导入到excel

原文:http://www.cnblogs.com/duduandermao/p/7411512.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!