S_No Operators About No.Of-Busses Main-Routes No.Of-Routes Popular-Routes
1 A-G-Holidays *** 10 Delhi - Haridwar Delhi - Haridwar
Delhi - Dehradun
Delhi - Kanpur
Delhi - Lucknow
Delhi - Rishikesh
Rishikesh - Delhi
Kanpur - Lucknow
Haridwar - Delhi
Haridwar - Rishikesh
Haridwar - Dehradun
blank line-----------------------------------------------------------------------
2 A-K-Travels *** 2 0
Mumbai - Indore
Indore - Mumbai
こんにちは、上記のExcelシートがあります。私はすべての一般的なルートを数え、対応するS_No行のNo.of-Routes列にその数を表示する必要があります。また、すべてのS_Noの後に空白行があります。そしてこれらのすべての一般的なルートは1つのセルに配置されません(各ルートは1つの行です)。 私は以下のコードを試しました。私は前進できません、助けてください。Excelからデータを取得し、JAVAを使用して行数をExcelに出力する
public class PrintNoOfRoutes
{
public static void main(String args[]) throws Exception
{
List list=new ArrayList();
FileInputStream file = new FileInputStream(new File("D:/BusOperators/sample.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.iterator();
rowIterator.next();
Row row = rowIterator.next();
int S_No=(int) row.getCell(0).getNumericCellValue();
System.out.println(S_No);
Iterator<Cell> cellIterator = row.cellIterator();
while(cellIterator.hasNext())
{
Cell cell = cellIterator.next();
switch(cell.getCellType())
{
case Cell.CELL_TYPE_BOOLEAN:
System.out.println("boolean===>>>"+cell.getBooleanCellValue() + "\t");
break;
case Cell.CELL_TYPE_NUMERIC:
int S_No=(int) row.getCell(0).getNumericCellValue();
System.out.println(S_No);
break;
case Cell.CELL_TYPE_STRING:
//list.add(cell.getStringCellValue());
if(c==S_No)
{
System.out.println("done");
row.getCell(6);
Row row2 = rowIterator.next();
if(cell.getStringCellValue() != null)
{
count=1;
System.out.println(count);
count++;
}
break;
}
は、実際には空白行ですか、空白行を含んでいますか?------------------------------- ---------------------------------------- '? – XtremeBaumer
No.その空(空白行) –