简体   繁体   English

设置单元格以读取表标题行

[英]Aspose cells to read table header row

How can i retrive excel table header row. 如何检索Excel表标题行。
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. ListObject.getDataRange()将仅返回数据行。

To get the header row, use ListObject.getListColumns(). 要获取标题行,请使用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. 我与Aspose合作担任开发人员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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