作者:乔山办公网日期:
返回目录:excel表格制作
上传一个你的样本文件看看?
你第三步下面那行代码是控制插入在哪一行的,你一直是0所以就覆盖了,你要让它每次加1.
String[] arr = new String[] { "a", "b", "c", "d", "a", "b", "c", "d", "a", "b", "c", "d" };
List<String> list = Arrays.asList(arr);
if (list != null) {
StringBuffer buff = new StringBuffer();
int colIndex = 0;// 用来标识抄列下标袭
for (int i = 0; i < list.size(); i++) {
if (i != 0 && i % 3 == 0) {// 不是百第一个下标并且能被度3整除,也就知是4个一个轮回道
buff.append(list.get(i));
rows.createCell(colIndex++).setCellValue(new String(buff));
buff = new StringBuffer();// 清空buff内容
} else {
buff.append(list.get(i));
}
}
}