将Excel列转换为字符串数组

时间:2014-08-25 12:59:54

标签: java arrays string excel

我在Excel中有一列单词,我想将其转换为字符串数组,这是一个很长的列表,我无法手动完成。我该怎么办?

我的擅长就像:

Car
House
Key
Phone
...

我希望我的数组如下:

"Car","House","Key","Phone",...

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以尝试使用Apache POI从excel中读取这些字符串并进行相应的操作

有关详情,请尝试查看http://viralpatel.net/blogs/java-read-write-excel-file-apache-poi/

答案 1 :(得分:0)

Aspose.Cells for Java是你的朋友。使用此代码将列的值读入字符串数组。

ArrayList<String> list = new ArrayList<>();

Workbook workbook = new Workbook("spreadsheet.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("Sheet1");
for (Object o: worksheet.getCells().getRows()) {
    Cell cell = ((Row) o).getCellByIndex(0);
    list.add(cell.getStringValueWithoutFormat());
}

com.aspose.cells.*导入类。在free temporary license之前的有限时间内享受purchasing

披露:我是Aspose的开发人员。