| View previous topic :: View next topic |
| Author |
Message |
EricR General User

Joined: 02 Aug 2004 Posts: 5
|
Posted: Fri Aug 06, 2004 6:40 am Post subject: Filtering in Calc |
|
|
Well. I first have to state that i'm a beginner in OOO and UNO.
My first try has been to write a macro to set up a filter from the current column and selected value and i've ended with the following :
| Code: |
Sub FiltrePareil
Dim MaCase As Object, MaFeuille as Object
MaFeuille = ThisComponent.CurrentController.ActiveSheet
MaCase = ThisComponent.CurrentSelection(0).GetCellByPosition(0,0)
MaColonne = MaCase.CellAddress.Column
MaValeur = MaCase.String
dim xFilterDesc as Object
xFilterDesc = MaFeuille.createFilterDescriptor(true)
dim aFilterFields(0) as new com.sun.star.sheet.TableFilterField
aFilterFields(0).Field = MaColonne
aFilterFields(0).IsNumeric = false
aFilterFields(0).Operator = com.sun.star.sheet.FilterOperator.EQUAL
aFilterFields(0).StringValue = MaValeur
xFilterDesc.setFilterFields(aFilterFields())
xFilterDesc.ContainsHeader = true
MaFeuille.filter(xFilterDesc)
end sub
|
I'm sure there is a better way to do it(feel free to give any comment) but that's not my current problem (at least that code runs fine in my case
In fact, i'd now like to be able to set the filtering off.
I've found that piece of code by recording a macro.
| Code: |
sub DesactiveFiltreStd
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:DataFilterRemoveFilter", "", 0, Array())
end sub
|
but i'm not sure i'm ready to use that dispatch thing and i'd like to stick to "basic" basic
So i wonder if a sheet (or a range) has a property indicating that a filter is active or not and if by setting that property to false i could do the job.
Or should i use the same kind of code with a empty FilterDescriptor ????
TIA for any hints
Eric
PS Sorry for my english. It's noot my native language  |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Fri Aug 06, 2004 1:29 pm Post subject: |
|
|
My guess is that you should simply set an empty filter descriptor.... _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
EricR General User

Joined: 02 Aug 2004 Posts: 5
|
Posted: Wed Aug 11, 2004 7:33 am Post subject: |
|
|
Yep .... that works
Thanks a lot
Eric |
|
| Back to top |
|
 |
|