Hallo Johannes,
Johannes A. Bodwing wrote:
Hallo Leute,
wie kriege ich eine Tabelle in Writer so sortiert, daß sie z.B.
alphabetisch aufsteigend vorliegt, von links oben nach rechts unten?
das würde/sollte grob so aussehen:
a b c
d e f
g h i
Versuch's mal mit nachfolgendem Makro, ich hab's TubbleSort gennant in
Anlehnung an den beliebten BubbleSort-Algorithmus.
Viel Erfolg damit...
Andreas
dim nrowcount as integer
dim ncolcount as integer
dim xtable as object
Sub TubbleSort
xdoc = thiscomponent
xtable = xdoc.gettexttables.getbyindex(0)
xrows = xtable.getrows()
xcols = xtable.getcolumns()
nrowcount = xrows.count()
ncolcount = xcols.count()
xnames = xtable.getcellnames()
for i=0 to nrowcount-1
for j=0 to ncolcount-1
for k=i+1 to nrowcount-1
SubSort(0,k,ncolcount-1,k,true)
next k
SubSort(ncolcount-1,0,ncolcount-1,nrowcount-1,false)
SubSort(0,i,ncolcount-1,i,false)
next j
next i
xdoc.refresh()
End Sub
Sub SubSort( c1, r1, c2, r2, descending )
xcellrange = xtable.getCellRangeByPosition( c1, r1, c2, r2 )
xsorter = xcellrange.createSortDescriptor()
if( descending ) then
sof = xsorter(4).value
sopt = sof(0)
sopt.isascending = false
sof(0) = sopt
xsorter(4).value = sof
endif
if( r2 > r1 ) then
xsorter(2).value = false
endif
xcellrange.sort( xsorter )
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]