各位好!
我要从数据库中将一张表的信息写入到excel中,但在遍历数据时出了问题,请问如何遍历才能得到将数据正确写
入到excle中,谢谢!
<code>
//创建新的Excel 工作簿
HSSFWorkbook workbook = new HSSFWorkbook();
//在Excel工作簿中创建一个名位FIRST的工作表
HSSFSheet sheet = workbook.createSheet("IPCount");

//在索引0的位置创建行,对应着第一行
HSSFRow row = sheet.createRow((short)0);
//在索引0的位置创建单元格,对应着第一行第一列的单元格
row.createCell((short) 0).setCellValue("TETRA Network");
row.createCell((short)1).setCellValue("Time");
row.createCell((short)2).setCellValue("CH_RES");
row.createCell((short)3).setCellValue("QUEUED_CH_RES");
row.createCell((short)4).setCellValue("TBSCallTime");
//从数据库中读取数据
List<Demo> demo = BeanFactory.getDemoDaoInstance().queryByAll();

//String[] dd = demo.toArray();
//int i = 0;
for(int i=1;i<demo.size()+1;i++)
{
row = sheet.createRow((short)i);

for(int j=0;j<5;j++)
{
//将读取到的数据填充到cell , 这里不知如何正确遍历将数据全部取出写入excel中
row.createCell((short)j).setCellValue("");

}
}

</code>