in com.sun.star.util.SortField quale è il metodo per non considerare la prima riga come intestazione?
Ho trovato ContainsHeader = false..... ma non riesco a farlo funzionare, ammesso che sia quello giusto.
Grazie
[Risolto] Metodo in .util.SortField per prima riga
[Risolto] Metodo in .util.SortField per prima riga
Ultima modifica di Avorio il domenica 27 aprile 2014, 18:30, modificato 2 volte in totale.
OpenOffice 4.0.1 su Windows Seven
Re: Metodo in com.sun.star.util.SortField per prima riga
Questo è quello che stò utilizzando
Codice: Seleziona tutto
sub Ordinatipo (foglio as string, rangesort as string, colonnaByposition as integer)
Dim oSheet as object , oCellRange as Object
Dim oSortFields(1) As New com.sun.star.util.SortField
Dim oSortDesc(0) As New com.sun.star.beans.PropertyValue
oSheet = ThisComponent.Sheets.getByName(foglio)
oCellRange = oSheet.getCellRangeByName(rangesort)
oSortFields(0).Field = colonnaByposition 'ordina da colonna...
oSortFields(0).SortAscending = True
oSortFields(0).ContainsHeader = False
'Setup the sort descriptor
oSortDesc(0).Name = "SortFields"
oSortDesc(0).Value = oSortFields()
oCellRange.Sort(oSortDesc()) 'Sort the range
End Sub
OpenOffice 4.0.1 su Windows Seven
Re: Metodo in com.sun.star.util.SortField per prima riga
prova questa, funziona
Codice: Seleziona tutto
sub prova
doc = ThisComponent
Sheet = doc.sheets(0)
ultimariga = 9
rng = "$A$1:$B$" & ultimariga
call ordina(rng)
end sub
sub ordina(rng)
dim document as object, dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = rng
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dim args2(9) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ByRows"
args2(0).Value = true
args2(1).Name = "HasHeader"
args2(1).Value = false
args2(2).Name = "CaseSensitive"
args2(2).Value = true
args2(3).Name = "NaturalSort"
args2(3).Value = false
args2(4).Name = "IncludeAttribs"
args2(4).Value = true
args2(5).Name = "UserDefIndex"
args2(5).Value = 0
args2(6).Name = "Col1"
args2(6).Value = 1 ' 1 o 2
args2(7).Name = "Ascending1"
args2(7).Value = true
args2(8).Name = "Col2"
args2(8).Value = 2
args2(9).Name = "Ascending2"
args2(9).Value = true
dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args2())
end sub-------------------
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Re: Metodo in com.sun.star.util.SortField per prima riga
oppure modifica la tua così:
Codice: Seleziona tutto
sub Ordinatipo (foglio as string, rangesort as string, colonnaByposition as integer)
Dim oSheet as object , oCellRange as Object
Dim oSortFields(1) As New com.sun.star.util.SortField ' <<<<
Dim oSortDesc(1) As New com.sun.star.beans.PropertyValue
oSheet = ThisComponent.Sheets.getByName(foglio)
oCellRange = oSheet.getCellRangeByName(rangesort)
oSortFields(0).Field = colonnaByposition 'ordina da colonna...
oSortFields(0).SortAscending = True
oSortDesc(0).Name = "SortFields"
oSortDesc(0).Value = oSortFields()
oSortDesc(1).Name = "ContainsHeader" ' <<<<
oSortDesc(1).value = false ' false non Contiene Header ' <<<<
oCellRange.Sort(oSortDesc()) 'Sort the range
End Sub-------------------
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Libre Office 7.5.3.2 su Windows 11
allega un file di esempio, guadagnerai tempo tu e lo farai risparmiare a chi ti aiuta
Re: Metodo in com.sun.star.util.SortField per prima riga
patel ha scritto:oppure modifica la tua così:
End Sub[/code]
Grazie, questa seconda soluzione mi piace di più.
OpenOffice 4.0.1 su Windows Seven
