Cloud Stack Ninja

Here is an example of what i could like to do: Excel Image

Is there a way to output all the cells between startprint and end_print, i've got like 3 sheet in excel with same place holder, and i want to view only the data between startprint and endprint, for now all i can do is print out all the 3 sheet with all the content, here is my code:

public class ReadInvoices {
    private static final String NAME = "C:\\Users\\.......\excelfilename.xlsx";

    public static void main(String[] args) {
        try {
            FileInputStream file = new FileInputStream(new File(NAME));
            Workbook workbook = new XSSFWorkbook(file);
            DataFormatter dataFormatter = new DataFormatter();
            Iterator<Sheet> sheets = workbook.sheetIterator();
            while(sheets.hasNext()) {
                Sheet sh =;
                System.out.println("Sheet name is "+sh.getSheetName());
                Iterator<Row> iterator = sh.iterator();
                while(iterator.hasNext()) {
                    Row row =;
                    Iterator<Cell> cellIterator = row.iterator();
                    while (cellIterator.hasNext()) {
                        Cell cell =;
                        String cellValue = dataFormatter.formatCellValue(cell);

        catch(Exception e) {



Read more here:

Content Attribution

This content was originally published by user3922899 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: