如何将Excel列复制到Java列表中

问题描述 投票:0回答:1

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

aspose aspose-cells
1个回答
0
投票

是的,可以使用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 the name of the cell found after searching worksheet
System.out.println("No. Of Rows Imported: " + dataTable.length);

.....

PS。我正在Aspose中担任支持开发人员/宣传人员。

© www.soinside.com 2019 - 2024. All rights reserved.