简体   繁体   中英

Aspose cells to read table header row

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();
    }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM