From a OpenOffice/LibreOffice Calc document created on code, the idea is to add a sheet as the first one and them remove all others (normally the document comes with 3 sheets).
It is using OLE on Windows from a xHarbour language program, but any language is ok if someone knows to do it on whatever language, translation is not a problem.
I got it working using the Sheet names. I think that this should be better using the indexes directly to remove them, but I was unable to do it with indexes only.
The code I got working is:
oPlan := oSheetDoc:GetSheets()
oPlan:insertNewByName("My New Sheet", 0)
DO WHILE oPlan:GetCount() > 1
oPlan:removeByName(oPlan:GetByIndex(oPlan:GetCount()-1):getName())
ENDDO
I think that should be a "remove by index" that I can't find on the online docs from OpenOffice.
Anybody knows if is there a way to do it only with indexes, or any way just better than I am doing?
According to https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=94494, sheets can only be removed by name.
oSheets = oDoc.Sheets
aSheetNames() = oSheets.getElementNames()
for iSheet = 1 to ubound(aSheetNames)
oSheets.removeByName(aSheetNames(iSheet))
next iSheet