1

How can i retrive excel table header row.
I able to retrive all rows except table header row.
Code

private static void printTableContent(final ListObject table) {
    System.out.println(table.getShowHeaderRow());
    Range range = table.getDataRange();

    for (int row = 0; row < range.getRowCount(); row++) {
        for (int column = 0; column < range.getColumnCount(); column++) {
            System.out.print(range.get(row, column).getDisplayStringValue());
            System.out.print("\t");
        }
        System.out.println();
    }
}
Ashish Aggarwal
  • 3,018
  • 2
  • 23
  • 46

1 Answers1

0

ListObject.getDataRange() will only return the data rows.

To get the header row, use ListObject.getListColumns(). Add the following code in your method to print the list of header row.

for (int iColumn = 0 ; iColumn < table.getListColumns().getCount() ; iColumn++)
{
    System.out.print(table.getListColumns().get(iColumn).getName());
}
System.out.println();

I work with Aspose as a Developer Evangelist.

Saqib Razzaq
  • 1,408
  • 1
  • 10
  • 10