How to Filter data using AutoFilter in Microsoft Spreadsheet with PHP using Aspose.Cells REST API?

Folks,

I’ve found several calls in the API documentation relating to auto-filters but keep getting an error response “UnsupportedApiVersion” when I try to add one using the following api call:

I have a feeling that I’m missing a step before calling the autofilter method but for the life can’t figure it out so any help/direction would be greatly appreciated.

I’m using the Cell Cloud product via the Laravel SDK (PHP), the SDK doesn’t actually contain a ready made call for this so I extended the class to add the functionality.

Thanks!

Trent

@trent.bean

Thank you for contacting support.

We are updating Aspose.Cells for Cloud PHP SDK to include all AutoFilter APIs. I will update you in this thread once the PHP SDK and Examples are updated.

@trent.bean

I am pleased to inform you that we have added AutoFilter APIs to Aspose.Cells PHP SDK. Examples are also added to GitHub repository that indicates how to use these APIs. Docs are also updated with PHP Examples.

Please contact us if there are any problems.

Dear Support Folks,

I was finally able to get back to this for testing and ran into another problem. It seems like I can only create one auto-filter at any given time. If I create an autofilter on multiple columns only the last one comes up with the autofilter. I thought it might be the field index, but all I get are out of range errors if I use anything other than 0.

Thanks!

Trent

@trent.bean

fieldIndex indicates Column index. You need to ensure you are setting an appropriate value to range parameter before setting fieldIndex. E.g. if I set range parameter value to “A1:C13” I can set fieldIndex to either 0, 1 or 2.
AutoFilter can be applied to one column at a time. If you want to apply a filter to multiple columns, you need to call the same API multiple times with different argument values (fieldIndex, criteria).

Dear Support,

It doesn’t seem like the filters are being saved in between autofilter requests. Here is a better example of what I’m experiencing:

  1. Create a new empty workbook.
  2. Add a Worksheet.
  3. Import data from a previously uploaded CSV file
  4. Freeze the first row
  5. Format the header row (bold/bgcolor/fontcolor)
  6. Add autofilters to each column in the header row by looping through the headers (see example curl PUT calls below)
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=A1:A7&fieldIndex=0&criteria=Location
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=B1:B7&fieldIndex=0&criteria=Bin
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=C1:C7&fieldIndex=0&criteria=Bin Zone
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=D1:D7&fieldIndex=0&criteria=Description
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=E1:E7&fieldIndex=0&criteria=Bin Pick Sort
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=F1:F7&fieldIndex=0&criteria=Created At
http://api.aspose.cloud/v1.1/cells/autofilter_test.xlsx/worksheets/Results/autoFilter/filter?range=G1:G7&fieldIndex=0&criteria=Date Retired 
  1. Auto size the columns
  2. Download the final document

The end result is only one autofilter on the last requested autofilter column. It is almost like it is not saving the document in between requests. If I stop the loop early, the autofilter resides on the stopped column.

Capture.PNG (4.8 KB)

Thanks!
Trent

@trent.bean

Thanks for using Aspose Cloud APIs.

Please check the examples on GitHub, it shows how we can apply filters to multiple columns.

Please pay close attention to the API parameters.

Please let us know if this helps you in fixing the issue.