简体   繁体   English

从第N个元素到excel中的最后一个元素使用JXL Java

[英]To get from N-th elements till the last elements in excel Using JXL Java

String dt=s.getCell(0,row).getContents();

How should I change it so I would be reading it starting from the fourth row till the last row? 我应该如何更改它,这样我才能从第四行开始阅读到最后一行? My code currently reads all the row from the first column. 我的代码当前从第一列读取所有行。 Any method I can use? 我可以使用任何方法吗?

Try this: 尝试这个:

for(int row = 3; row < s.getRows(); row++){
   String dt=s.getCell(0,row).getContents();
   ...
}

This will loop through all the rows, starting from the 4th one int row = 3 , if you want to start from another row, just change the initial value of the row variable (keep in mind that rows indexing starts at 0), if you want to get all the cells of all the rows after the 4th one, you can do it like this: 这将从第4个int row = 3开始循环遍历所有行,如果要从另一行开始,则只需更改row变量的初始值(请注意,行索引从0开始),如果您要想要获取第4行之后所有行的所有单元格,可以这样进行:

for(int row = 3; row < s.getRows(); row++){
   Cell[] cells = s.getRow(row);
   for(Cell cell:cells){
      String dt= cell.getContents();
      ....
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM