sUrl = "private:factory/scalc"
oDoc = StarDesktop.loadComponentFromURL(sUrl,"_default",0, Array())
Se si intende lavorare con il documento corrente invece:
oCalcDocument = StarDesktop.getCurrentComponent()
oCalcDocument = ThisComponent
oSheets = oCalcDocument.getSheets()
Come recuperare le singole tabelle:
Medante indice:
oCalcSheet = oSheets.getByIndex(0) ' forma equivalente abbreviata: oCalcSheet = oSheets(0)
- Mediante il nome:
oCalcSheet = oSheets.getByName("Tabella2") ' anche in questo caso esiste una forma equivalente abbreviata: oCalcSheet = oSheets("Tabella2")
Rinominare una tabella
oSheets("Tabella1").Name = "Nuovo nome"
Spostare una tabella:
'spostiamola dopo la terza tabella (all'ultima posizione) oSheets.moveByName( "Tabella1", 3)
Aggiungere una tabella:
Il metodo insertNewByName provvede a creare una nuova tabella e inserirla nella posizione specificata. Il metodo prende 2 argomenti: il nome della tabella da creare e la posizione di inserimento.oSheets.insertNewByName("Nuova Tabella",3)
Eliminare una tabella:
Questo metodo richiede un solo parametro: il nome della tabella da eliminare.oSheets.removeByName("Nuova Tabella")
Proteggere / sproteggere una tabella:
oSheets("Tabella1").protect("Password")
oSheets("Tabella1").unprotect("Password")Print "la tabella: " & oCalcSheet.Name & " è protetta!"
End If
Nascondere/mostrare una tabella:
Occorre ricordare che almeno una tabella deve essere sempre visibile, ovvero non è possibile nascondere tutte le tabelle' nasconde la tabella oSheets("Tabella1").IsVisible = False ' mostra la tabella oSheets("Tabella1").IsVisible = True
Contare le tabelle:
Print oSheets.getCount()
Enumerare le tabelle:
For I = 0 to oSheets.Count -1 oCalcSheet = oSheets.getByIndex(I) print oCalcSheet.Name Next I
For Each oCalcSheet In oSheets Print oCalcSheet.Name Next
Rendere attiva una tabella:
oView = oCalcDocument.getCurrentController() oCalcSheet = oSheets("Tabella2") oView.setActiveSheet(oCalcSheet)













