在我的工作中,我使用的是 cells-2.3.1.jar。我想过滤列并使用这些过滤值,而不保存到文件并重新加载它,只在内存中工作。
这是我的代码:
Worksheet worksheet = workbook.getWorksheets().getSheet(0);
AutoFilter autoFilter = worksheet.getAutoFilter();
autoFilter.filter(2, nameValue);
autoFilter.filter(4, countryValue);
// At this point if I insert workbook.save("file.xls"), this file contains the right values
//But I don't need and don´t want to write to disk
//However shows all the values
Cells cells = worksheet.getCells();
for (int fila = 1; fila <= cells.getMaxRow(); fila++) {
System.out.println("Name: " + ((String) cells.getCell(fila,2).getValue()).trim());
System.out.println("Country: " + ((String) cells.getCell(fila, 4).getValue()).trim());
}
对不起我的英语不好。提前谢谢。