[Solved] Remove a Filter from Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Rajagopalanta
Posts: 31
Joined: Tue Jan 27, 2009 4:23 pm

[Solved] Remove a Filter from Calc

Post 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
Last edited by Rajagopalanta on Fri Sep 25, 2009 2:02 pm, edited 1 time in total.
OOo 3.0.X on Ms Windows XP
FJCC
Moderator
Posts: 9543
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Remove a Filter from Calc

Post by FJCC »

You can make the rows visible again with

Code: Select all

xRange.Rows.Isvisible = True
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: [Solved] Remove a Filter from Calc

Post by pitonyak »

You will likely find this document interesting

http://www.pitonyak.org/database/Calc_A ... tabase.odt
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
Post Reply