I'd like to know how to order may sheets in an alphabetical order. For example I have many patients and each one has its own sheet. I need to order them to find a patient easily.
Thanks
Ordering sheets
Ordering sheets
BrOffice.org 3.0.0 OOO300m9
OS Windows Xp
OS Windows Xp
Re: Ordering sheets
I don't know of a built in way to do that. Here is a simple macro that should work
Code: Select all
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
Sheets = ThisComponent.Sheets
Names = Sheets.ElementNames
SortedList = BubbleSortList(Names) 'BubbleSortList is a macro in the Tools Library
for i = 0 to UBound(SortedList)
Sheets.MoveByName(SortedList(i), i)
next i
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Ordering sheets
Python can sort lists:
Code: Select all
import uno
def sortSheets():
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.getSheets()
c = sheets.getCount()
t = sheets.getElementNames()
l = list(t)
l.sort()
for n in range(c):
sheets.moveByName(l[n],n)
g_exportedScripts = sortSheets,
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Ordering sheets
Hallo
@Villeroy:
slightly more readable:
Karo
@Villeroy:
slightly more readable:
Code: Select all
def sheets_sort():
doc = XSCRIPTCONTEXT.getDocument()
sheets = doc.getSheets()
sheetnames = sorted( sheets.getElementNames() )
for i, sheet in enumerate( sheetnames ):
sheets.moveByName( sheet, i)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Re: Ordering sheets
Thank you. That's a lot more readable and shorter. I'm not very profiecient in Python programming and did not even search for a built-in function. Instead I accessed the list object I knew to be sortable.karolus wrote:Hallo
@Villeroy:
slightly more readable:
Karo
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Ordering sheets
It seems Letto uses BrOffice.org 3.0.0 OOO300m9 which uses Python 2.3.X. sorted function is new feature of Python 2.4, so importing the function from __feature__ module is required, I suppose.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: Ordering sheets
Hi,
how to change that basic macro to sort all the sheets except the first and second, and a sheet named 'NoSortSheet'? I can not deal with it , please help.
how to change that basic macro to sort all the sheets except the first and second, and a sheet named 'NoSortSheet'? I can not deal with it , please help.
OpenOffice 3.4.1 on WinXP/Win7/Win8