Forum > FPSpreadsheet

Filtering rows in FPSpreadsheet


Dear ALL,

I have a spreadsheet with data on plant specimens collected in some plots. The spreadsheet is read using the great FPSpreadsheet component ( I want to be able to filter the rows of the spreadsheet, by executing SQL-like queries on the data (eg., for displaying only the plants belonging to a certain family, or all specimens from a given family collected at a certain locality, etc.) and displaying the filtered results in the same (or another) spreadsheet.

One way I devised (but have not tested!) of achieving that would involve exporting the spreadsheet data to a csv file and then using the ZMSQL ( component for performing the query on the data and display the results. But this seems very convoluted. Is there a way of doing this using only FPSpreadsheet?

I attach a sample project, including the original data spreadsheet in Excel97 format. This project includes a gross filter dialog (which is incomplete and buggy, but it should suffice to convey the general idea) to build SQL-like queries. See also the attached screenshot.

Thanks in advance for any assistance you can provide!

With best wishes,

Why don't you do like I did in the sample code I presented in the related thread (,55981.0.html)? Iterate through all rows, find out which row matches your filter criterion, and then copy the cells from the matching rows to a new empty worksheet.

Dear @wp,

--- Quote ---Why don't you do like I did in the sample code I presented in the related thread
--- End quote ---

But I did! I loved it! (Haven't you seen my reply in that thread?), but it did not occurred to me that it could be extended to the more general case of filtering rows according to the criteria provided by the user. I am still quite new to FPSpreadsheet, and learning its functionalities step by step.

BTW, if I may make a suggestion: wouldn't it be possible (and useful) to have a property 'Filter' added to a worksheet, which would take a user-provided SQL-like query for filtering the displayed rows of a spreadsheet?

With best wishes,


[0] Message Index

Go to full version