【发布时间】:2020-02-18 19:06:28
【问题描述】:
我想使用 Aspose 库将 Excel 工作表中的整个列提取到 Java 数组中。我怎么做?在许多示例中,我看到了如何将列/行从一个工作表复制到另一个工作表。 Aspose 可以提取数据吗?
【问题讨论】:
标签: aspose aspose-cells
我想使用 Aspose 库将 Excel 工作表中的整个列提取到 Java 数组中。我怎么做?在许多示例中,我看到了如何将列/行从一个工作表复制到另一个工作表。 Aspose 可以提取数据吗?
【问题讨论】:
标签: aspose aspose-cells
是的,可以使用 exportArray 方法轻松地将数据导出到数组中,请参阅示例代码供您参考:
示例
// Instantiating a Workbook object
Workbook workbook = new Workbook("Book1.xlsx");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);
// Exporting the contents of 100 rows and 1 column starting from 1st cell (i.e., A1:A100)
// to Array. you may update the method parameters for your needs
Object dataTable[][] = worksheet.getCells().exportArray(0, 0, 100, 1);
// Printing number of rows after exporting worksheet data
System.out.println("No. Of Rows Imported: " + dataTable.length);
.....
PS。我在 Aspose 担任支持开发人员/布道者。
【讨论】: