如何将 Excel 列复制到 Java 列表

How to copy a Excel column to a Java list

我想使用 Aspose 库将整个列从 excel 工作表提取到 Java 数组。我怎么做?在许多示例中,我看到了如何将 column/row 从一个工作表复制到另一个工作表。 Aspose可以提取数据吗?

是的,使用exportArray方法可以很方便的将数据导出到Array中,参考示例代码:

例子

// 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 担任支持开发人员/传播者。