I\'m using the Apache POI library, but I have some data that I don\'t want to be read - So I need the program to start reading the file from a specific row.
I want a
Refer below:
String fileName = "D:\\TestScripts.xls"; // file
POIFSFileSystem fileSystem = new POIFSFileSystem(new FileInputStream(fileName));
HSSFWorkbook workbook = new HSSFWorkbook(fileSystem);
// HSSFSheet sheet = workbook.getSheetAt(0); //Get first Excel Sheet
HSSFSheet sheet = workbook.getSheet("SheetName"); //Get data as per sheet name
for (Row row : sheet) { // For each Row.
Cell cell = row.getCell(0); // Get the Cell at the Index / Column you want.
if(cell.getStringCellValue().equalsIgnoreCase("test")) {
System.out.println(cell.getRow().getLastCellNum());
for(int i=0;i<=cell.getRow().getLastCellNum()-1;i++) {
System.out.println(cell.getRow().getCell(i));
}
}
}
Remove below condition if you are not looking for any particular column data
if(cell.getStringCellValue().equalsIgnoreCase("test"))
Note: you need to change the test from above code with your column name like id, name as per your sheet data header