Ayuda de LibreOffice 7.4
The SFDocuments shared library provides a number of methods and properties to facilitate the management and handling of LibreOffice documents.
The SFDocuments.Calc service is a subclass of the SFDocuments.Document service. All methods and properties defined for the Document service can also be accessed using a Calc service instance.
The Calc service is focused on:
Handling sheets within a Calc document (copy, insert, move, etc)
Exchanging data between Basic data structures and Calc ranges
Copying and importing massive amounts of data
This help page describes methods and properties that are applicable only to Calc documents.
Antes de utilizar el servicio Calc, es necesario cargar o importar la biblioteca ScriptForge:
The Calc service is closely related to the UI service of the ScriptForge library. Below are a few examples of how the Calc service can be invoked.
The code snippet below creates a Calc service instance that corresponds to the currently active Calc document.
Set oDoc = CreateScriptService("Calc")
Another way to create an instance of the Calc service is using the UI service. In the following example, a new Calc document is created and oDoc is a Calc service instance:
Dim ui As Object, oDoc As Object
Set ui = CreateScriptService("UI")
Set oDoc = ui.CreateDocument("Calc")
Or using the OpenDocument method from the UI service:
Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods")
It is also possible to instantiate the Calc service using the CreateScriptService method:
Dim oDoc As Object
Set oDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods")
In the example above, "MyFile.ods" is the name of an open document window. If this argument is not provided, the active window is considered.
Es recomendable liberar recursos después del uso:
Set oDoc = oDoc.Dispose()
However, if the document was closed using the CloseDocument method, it becomes unnecessary to free resources using the command described above.
myDoc = CreateScriptService("Calc")
ui = CreateScriptService("UI")
myDoc = ui.CreateDocument("Calc")
myDoc = ui.OpenDocument(r"C:\Documents\MyFile.ods")
myDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods")
myDoc.Dispose()
El uso del prefijo «SFDocuments.» al llamar el servicio es facultativo.
Many methods require a "Sheet" or a "Range" as argument. Single cells are considered a special case of a Range.
Both may be expressed either as a string or as a reference (= object) depending on the situation:
Within a specific Calc instance, sheets and ranges are given as strings such as "Sheet1" and "D2:F6".