0

In my work i am using cells-2.3.1.jar. I want to filter columns and work with those filtered values, without save to file and reload it, just working in memory.

This is my code:

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());
        }

Sorry for my english. Thanx in advance.

  • You can also save the workbook to memory, instead of saving to disk. See http://www.aspose.com/community/forums/thread/423364/convert-to-csv-in-memory-instead-of-save-to-disk-or-create-an-md5-hash.aspx for example – Saqib Razzaq Oct 28 '14 at 17:45

1 Answers1

0

Here there is an example http://www.aspose.com/docs/display/cellsjava/AutoFilter where it saves in the disk the workbook, just you did; so I think that you just have to keep a reference to your Worksheet object

rickyalbert
  • 2,552
  • 4
  • 21
  • 31