Hi,
Is there currently a way to apply a unique-only filter to the data in a worksheet? As you can do in Excel by Data --> Filter --> Advanced Filter --> Unique records only…
I’ve looked at the API for Aspose.Cells Java and can’t find a similar method…
Thanks,
Daniel
Hi Daniel,
Thank you for considering Aspose.
Well, I am afraid; your requested feature is not support yet. We have registered your request in our issue tracking system with issue id CELLSJAVA-11810. We will check the feasibility of this feature and see if we can support it soon as per your requirement.
Thank You & Best Regards,
Hi Daniel,
Thank you for considering Aspose.
Currently there is no such API for unique-only filter. However, it is easy for you to write your own code and following code is an example:
private static void filterUnique(Cells cells, int startRow, int startCol, int endRow, int endCol)
{
ArrayList<Object> alUnique = new ArrayList<Object>((endRow-startRow+1)/2+1);
for(int i=startCol; i<endCol; i++)
{
alUnique.clear();
Iterator<Row> iterRow = cells.getRowIterator(startRow);
while(iterRow.hasNext())
{
Row row = iterRow.next();
if(row.getRowIndex() > endRow)
{
break;
}
if(row.isHidden())
{
continue;
}
Cell cell = row.checkCell(i);
if(cell == null)
{
continue;
}
Object v = cell.getValue();
if(v == null)
{
continue;
}
boolean unique = true;
for(Object exist : alUnique)
{
if(exist.equals(v))
{
row.setHidden(true);
unique = false;
break;
}
}
if(unique)
{
alUnique.add(v);
}
}
}
}
Thank You & Best Regards,