LGAP
LGAP

Reputation: 2453

Using Apache POI reading columns of a excel sheet

My excel sheet contains many columns and many rows.

I want the program to read the contents of first column alone and display in the output.

Using

    for (Row row : sheet) {
    for (Cell cell : row) {
        // Printing Stuff
        }
    }

The above code prints the contents of all the cells of the excel sheet. But I want the contents of first column alone to be printed.

How to alter the code for this? Am a beginner in java. Please help

Upvotes: 2

Views: 4582

Answers (1)

Colin Hebert
Colin Hebert

Reputation: 93157

You can try this :

for (Row row : sheet) {
    Cell firstCell = row.getCell(0);
    // Printing Stuff
}

Resources :

Upvotes: 4

Related Questions