admin管理员组文章数量:1122846
I have a code. I'm incrementing colnum variable to read from all columns of a table in pdf. If I type colnum = colnum + 3 to skip column reads, only tabledatalines[0] is read. File writing after the two loops do not execute. Without colnum = colnum + 3, I get print and file writing. rownum++ and m++ work normally. Please help
This is my code -
String tabledata = docText.substring(docText.indexOf("Date"));
System.out.println(tabledata);
int rownum = 3, m = 0, colnum = 0;
String[] tabledatalines = tabledata.split("\n");
for(String a : tabledatalines)
{
Row row = sheet1.createRow(rownum);
String[] tabledatawords = tabledatalines[m].split(" ");
for(colnum = 0; colnum < tabledatawords.length; colnum++)
{
//if(rownum==3)
//if(colnum == 1)
// colnum++;
if(tabledatawords[colnum].startsWith("________________________"))
break;
//if(tabledatawords[colnum].startsWith("Total"))
// colnum = colnum + 3;
if(colnum<2)
{
cell = row.createCell(colnum);
cell.setCellValue(tabledatawords[colnum]);
System.out.println("Cell data: " + tabledatawords[colnum]);
}
if(colnum>=2)
{
cell = row.createCell(colnum+1);
cell.setCellValue(tabledatawords[colnum]);
}
System.out.println("Colnum: " + colnum);
}
rownum++;
colnum = 0;
m++;
}
FileOutputStream fout = new FileOutputStream(filex);
workbook.write(fout);
fout.close();
System.out.println("File written");
pdfDocument.close();
fis.close();
}
catch(Exception ex)
{
}
}
本文标签: excelCannot do colnumStack Overflow
版权声明:本文标题:excel - Cannot do colnum++ - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304390a1932217.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论