Write data into Excel sheet java

爷,独闯天下 提交于 2019-12-06 08:02:10

Assuming your lists are all the same size, why not something like:

Sheet s = wb.createSheet();
for (int i=0; i<firstList.size(); i++) {
   Row r = s.createRow(i);
   r.createCell(0).setCellValue( list1.get(i) );
   r.createCell(1).setCellValue( list2.get(i) );
   r.createCell(2).setCellValue( list3.get(i) );
}

Add extra error handling if your lists might not be the same length, and extra logic if you need to do formatting / dates / etc for the list contents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!