Page 1 of 1

[Solved] Remove a Filter from Calc

Posted: Wed Sep 23, 2009 4:26 pm
by Rajagopalanta
Hi,

I want to know, how to remove a filter that is there in a calc sheet. In the below code, I set the filter and change the contents of filtered sheet, now I want to remove the filter, so that the sheet looks without any hidden rows...

I filter Column A and update column B on the filtered result...

Code: Select all

	Dim xRange as object
	Dim FilterDesc as Object
	Dim FilterFields(0) as new com.sun.star.sheet.TableFilterField

	xRange = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A2:C12")
	FilterDesc = xRange.createFilterDescriptor(true)
	
	FilterDesc.ContainsHeader = true
	FilterFields(0).Field = 0
	FilterFields(0).IsNumeric = true
	FilterFields(0).Operator = com.sun.star.sheet.FilterOperator.GREATER_EQUAL
	FilterFields(0).NumericValue = 3
	FilterDesc.SetFilterFields(FilterFields)
	
	xRange.Filter(FilterDesc)
	
	Dim xRange1 as Object
	Dim Rngs as Object
	xRange1 = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("B2:B12")
	
	Rngs = xRange1.QueryVisibleCells()
	
	for each c in Rngs.Cells
		c.setString("Hai")
	next c

'  Need to remove the filter here... How ???

End Sub

Any help to improve this macro is also appreciated.

- Raja

Re: Remove a Filter from Calc

Posted: Wed Sep 23, 2009 5:22 pm
by FJCC
You can make the rows visible again with

Code: Select all

xRange.Rows.Isvisible = True

Re: [Solved] Remove a Filter from Calc

Posted: Thu Oct 01, 2009 6:15 am
by pitonyak
You will likely find this document interesting

http://www.pitonyak.org/database/Calc_A ... tabase.odt