SFDocuments.Calc zerbitzua

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:

note

This help page describes methods and properties that are applicable only to Calc documents.


Zerbitzuari deitzea

Calc zerbitzua eta UI ScriptForge liburutegiaren zerbitzua estu lotuta daude. Behean ageri dira Calc zerbitzua deitzeko moduak adierazten dituzten zenbait adibide.

Basic lengoaian

Beheko kode-zatiak uneko Calc dokumentu aktiboari dagokion Calc zerbitzu-instantzia bat sortzen du.


    Set oDoc = CreateScriptService("Calc")
  

Calc zerbitzuaren beste instantzia bat sortzeko beste modu bat UI zerbitzua erabiltzea da. Hurrengo adibidean, Calc dokumentu berria sortzen da eta oDoc elementua Calc zerbitzuaren instantzia bat da:


    Dim ui As Object, oDoc As Object
    Set ui = CreateScriptService("UI")
    Set oDoc = ui.CreateDocument("Calc")
  

Edo UI zerbitzuaren OpenDocument metodoa erabilita:


    Set oDoc = ui.OpenDocument("C:\Documents\MyFile.ods")
  

Posible da, baita ere, Calc zerbitzuaren instantzia bat sortzea CreateScriptService metodoa erabilita:


    Dim oDoc As Object
    Set oDoc = CreateScriptService("SFDocuments.Calc", "MyFile.ods")
  

Goiko adibidean, "MyFile.ods" dokumentu-leiho ireki baten izena da. Argumentu hori ematen ez bada, leiho aktiboa erabiliko da.

Gomendagarria da baliaboideak askatzea erabileraren ondoren:


    Set oDoc = oDoc.Dispose()
  

Hala ere, dokumentua CloseDocument metodoa erabilita itxi bada, ez da beharrezkoa baliabideak askatzea goian deskribatutako komandoaren bidez.

Python lengoaian

    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()
  
tip

"SFDocuments." aurreizkia erabiltzea aukerakoa da zerbitzuari deitzen zaionean.


Definizioak

Metodo askok "Orria" edo "Barrutia" behar dute argumentu gisa. Gelaxka bakunak Range elementuaren kasu berezitzat hartzen dira.

Biak ala biak kate gisa edo erreferentzia (=objektu) gisa adierazi daitezke, egoeraren arabera:

Adibidea:

Beheko adibideak (soilik irakurtzeko moduan eta ezkutuan irekitako) A dokumentuko datuak B dokumentura kopiatzen ditu.

Basic lengoaian

    Dim oDocA As Object, oDocB As Object
    Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
    Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
    oDocB.CopyToRange(oDocA.Range("SheetX.D4:F8"), "D2:F6") 'CopyToRange(source, target)
  
Python lengoaian

    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopyToRange(docA.Range("SheetX.D4:F8"), "D2:F6")
  

SheetName

Sartu orri-izena .Sheet propietateak ekoiztutako string edo object gisa.

"~" (tildea) lasterbideak uneko orria ordezkatzen du.

RangeName

Uneko instantziako orri batean kokatutako elkarren ondoko gelaxken multzo bat adierazten duen kate bat edo .Range propietateak ekoiztutako object bat.

"~" (tileta) lasterbideak ordezkatzen du uneko hautapena edo hautatutako lehen barrutia, barruti anitz hautatuta badaude.

"*" lasterbideak erabilitako gelaxka guztiak ordezkatzen ditu.

Orri-izena aukerakoa da barruti batean (lehenespena = orri aktiboa). Komatxo bakun inguratzaileak eta $ ikurrak onartzen dira, baina ez ikusiarena egingo zaie.

tip

CurrentSelection propietatean salbu, Calc zerbitzuak gelaxken barruti bakunak soilik hartzen ditu kontuan.


Baliozko barrutien adibideak

1) '$OrriaX'.D2
2) $D$2

Gelaxka bakarra

1) '$OrriaX'.D2:F6
2) D2:D10

Barruti bakarra gelaxka anitzekin

'$OrriaX'.*

Emandako orrian erabilitako gelaxka guztiak

1) '$OrriaX'.A:A (A zutabea)
2) 3:5 (3 eta 5 arteko errenkadak)

Elkarren ondoko zutabe edo errenkaden gelaxka guztiak, erabilitako azken gelaxkaraino

nireBarrutia

"nireBarrutia" deitutako barruti bat kalkulu-orriaren mailan

1) ~.barrutiBat
2) OrriaX.barrutiBat

Barruti-izen bat orri-mailan

nireDok.Range("OrriaX.D2:F6")

'OrriaX' orriaren barruko barruti bat 'nireDok' Calc instantziarekin lotutako fitxategian

~.~ edo ~

Orri aktiboaren uneko hautapena


Propietateak

Edozein dokumentutarako orokorrak diren propietateak inplizituki Calc dokumentuetan ere aplikatu daitezke. Informazio gehiagorako, ikus Document zerbitzuaren laguntza-orria.

Calc dokumentuetan espezifikoki erabilgarri dauden propietateak honakoak dira:

Izena

Irakurtzeko soilik

Argumentua

Return type

Deskribapena

CurrentSelection

Ez

Bat ere ez

Katea edo kateen matrizea

The single selected range as a string or the list of selected ranges as an array.

FirstCell

Yes

SheetName or RangeName as String

String

Returns the first used cell in a given range or sheet.

FirstColumn

Yes

SheetName or RangeName as String

Long

Returns the leftmost column number in a given range or sheet.

FirstRow

Yes

SheetName or RangeName as String

Long

Returns the topmost row number in a given range or sheet.

Height

Bai

BarrutiIzena As String

Long

The number of rows (>= 1) in the given range.

LastCell

Bai

SheetName or RangeName as String

String

Returns the last used cell in a given range or sheet.

LastColumn

Bai

SheetName or RangeName as String

Long

The last used column in a given range or sheet.

LastRow

Bai

SheetName or RangeName as String

Long

The last used row in a given range or sheet.

Range

Bai

BarrutiIzena As String

Object

A range reference that can be used as argument of methods like CopyToRange.

Region

Yes

RangeName As String

String

Returns the address of the smallest area that contains the specified range so that the area is surrounded by empty cells or sheet edges. This is equivalent to applying the shortcut to the given range.

Sheet

Bai

OrriIzena As String

Object

A sheet reference that can be used as argument of methods like CopySheet.

Sheets

Bai

Bat ere ez

Kate-matrizea

The list with the names of all existing sheets.

Width

Bai

BarrutiIzena As String

Long

The number of columns (>= 1) in the given range.

XCellRange

Bai

BarrutiIzena As String

Object

A com.sun.star.Table.XCellRange UNO object.

XSheetCellCursor

Yes

RangeName As String

Object

A com.sun.star.sheet.XSheetCellCursor UNO object. After moving the cursor, the resulting range address can be accessed through the AbsoluteName UNO property of the cursor object, which returns a string value that can be used as argument for properties and methods of the Calc service.

XSpreadsheet

Bai

OrriIzena As String

Object

A com.sun.star.sheet.XSpreadsheet UNO object.


tip

Visit LibreOffice API Documentation's website to learn more about XCellRange, XSheetCellCursor and XSpreadsheet UNO objects.


Metodoak

Calc zerbitzuaren metodo-zerrenda

A1Style
Activate
Charts
ClearAll
ClearFormats
ClearValues
CopySheet
CopySheetFromFile
CopyToCell
CopyToRange
CreateChart
DAvg
DCount
DMax

DMin
DSum
Forms
GetColumnName
GetFormula
GetValue
ImportFromCSVFile
ImportFromDatabase
InsertSheet
MoveRange
MoveSheet
Offset
OpenRangeSelector

PrintOut
Printf
RemoveSheet
RenameSheet
SetArray
SetValue
SetCellStyle
SetFormula
ShiftDown
ShiftLeft
ShiftRight
ShiftUp
SortRange


A1Style

Returns a range address as a string based on sheet coordinates, i.e. row and column numbers.

If only a pair of coordinates is given, then an address to a single cell is returned. Additional arguments can specify the bottom-right cell of a rectangular range.

Sintaxia:

svc.A1Style(row1: int, column1: int, row2: int = 0; column2: int = 0; sheetname: str = "~"): str

Parametroak:

row1, column1: Specify the row and column numbers of the top-left cell in the range to be considered. Row and column numbers start at 1.

row2, column2: Specify the row and column numbers of the bottom-right cell in the range to be considered. If these arguments are not provided, or if values smaller than row1 and column1 are given, then the address of the single cell range represented by row1 and column1 is returned.

sheetname: The name of the sheet to be appended to the returned range address. The sheet must exist. The default value is "~" corresponding to the currently active sheet.

Adibidea:

The examples below in Basic and Python consider that "Sheet1" is the currently active sheet.

Basic lengoaian

    Set oDoc = CreateScriptService("Calc")
    addr1 = oDoc.A1Style(1, 1) ' '$Sheet1'.$A$1
    addr2 = oDoc.A1Style(2, 2, 3, 6) ' '$Sheet1'.$B$2:$F$3
    addr3 = oDoc.A1Style(2, 2, 0, 6) ' '$Sheet1'.$B$2
    addr4 = oDoc.A1Style(3, 4, 3, 8, "Sheet2") ' '$Sheet2'.$D$3:$H$3
    addr5 = oDoc.A1Style(5, 1, SheetName := "Sheet3") ' '$Sheet3'.$A$5
  
Python lengoaian

    doc = CreateScriptService("Calc")
    addr1 = doc.A1Style(1, 1) # '$Sheet1'.$A$1
    addr2 = doc.A1Style(2, 2, 3, 6) # '$Sheet1'.$B$2:$F$3
    addr3 = doc.A1Style(2, 2, 0, 6) # '$Sheet1'.$B$2
    addr4 = doc.A1Style(3, 4, 3, 8, "Sheet2") # '$Sheet2'.$D$3:$H$3
    addr5 = doc.A1Style(5, 1, sheetname="Sheet3") # '$Sheet3'.$A$5
  
tip

The method A1Style can be combined with any of the many properties and methods of the Calc service that require a range as argument, such as GetValue, GetFormula, ClearAll, etc.


Activate

If the argument sheetname is provided, the given sheet is activated and it becomes the currently selected sheet. If the argument is absent, then the document window is activated.

Sintaxia:

svc.Activate(sheetname: str = ""): bool

Parametroak:

OrriIzena: Dokumentuan aktibatuko den orriaren izena. Balio lehenetsia kate hutsa da, horrek esan nahi du dokumentu-leihoa orri aktiboa aldatu gabe aktibatuko dela.

Adibidea:

Beheko adibideak "Sheet4" izeneko orria aktibatzen du uneko dokumentu aktiboan.

Basic lengoaian

    Dim ui as Variant, oDoc as Object
    Set ui = CreateScriptService("UI")
    Set oDoc = ui.GetDocument(ui.ActiveWindow)
    oDoc.Activate("Sheet4")
  
Python lengoaian

    ui = CreateScriptService("UI")
    myDoc = ui.GetDocument(ui.ActiveWindow)
    myDoc.Activate("Sheet4")
  
tip

Orri bat aktibatzea zentzuzkoa izateko, Calc dokumentu batean egin behar da. Calc dokumentu bat eskura duzula ziurtatzeko, erabili dokumentu-objektuaren isCalc propietatea. Horrek True (egia) itzuliko du Calc dokumentu bat bada eta False (faltsua) ez bada.


Charts

Returns either the list with the names of all chart objects in a given sheet or a single Chart service instance.

Sintaxia:

svc.Charts(sheetname: str, chartname: str = ""): obj

Parametroak:

sheetname: The name of the sheet from which the list of charts is to be retrieved or where the specified chart is located.

chartname: The user-defined name of the chart object to be returned. If the chart does not have a user-defined name, then the internal object name can be used. If this argument is absent, then the list of chart names in the specified sheet is returned.

tip

Use the Navigator sidebar to check the names assigned to charts under the OLE objects category.


Adibidea:

Basic lengoaian

The example below shows the number of chart objects in "Sheet1".


    Dim arrNames as Object
    arrNames = oDoc.Charts("Sheet1")
    MsgBox "There are " & UBound(arrNames) + 1 & " charts in Sheet1"
  

The following example accesses the chart named "MyChart" in "Sheet1" and prints its type.


    Dim oChart as Object
    oChart = oDoc.Charts("Sheet1", "MyChart")
    MsgBox oChart.ChartType
  
Python lengoaian

    bas = CreateScriptService("Basic")
    chart_names = doc.Charts("Sheet1")
    bas.MsgBox(f"There are {len(chart_names)} charts in Sheet1")
  

    chart = doc.Charts("Sheet1", "MyChart")
    bas.MsgBox(chart.ChartType)
  

ClearAll

Emandako barrutiaren eduki eta formatu guztiak garbitzen ditu.

Sintaxia:

svc.ClearAll(range: str)

Parametroak:

range: Garbituko den barrutia, kate gisa.

Adibidea:

Basic lengoaian

      oDoc.ClearAll("SheetX.A1:F10")
  
Python lengoaian

    myDoc.ClearAll("SheetX.A1:F10")
  

ClearFormats

Emandako barrutiaren formatuak eta estiloak garbitzen ditu.

Sintaxia:

svc.ClearFormats(range: str)

Parametroak:

range: Formatuak eta estiloak garbituko zaizkion barrutia, kate gisa.

Adibidea:

Basic lengoaian

      oDoc.ClearFormats("SheetX.*")
  
Python lengoaian

    myDoc.ClearFormats("SheetX.*")
  

ClearValues

Emandako barrutiaren balioak eta formulak garbitzen ditu.

Sintaxia:

svc.ClearValues(range: str)

Parametroak:

range: Balioak eta formulak garbituko zaizkion barrutia, kate gisa.

Adibidea:

Basic lengoaian

      oDoc.ClearValues("SheetX.A1:F10")
  
Python lengoaian

    myDoc.ClearValues("SheetX.A1:F10")
  

CopySheet

Zehaztutako orria lehendik dagoen orri baten aurrean edo orri-zerrendaren amaieran kopiatzen du. Kopiatuko den orriak barruan edozein Calc dokumentu ireki eduki behar du. True (egia) itzultzen du ongi egiten bada.

Sintaxia:

svc.CopySheet(sheetname: any, newname: str, [beforesheet: any]): bool

Parametroak:

sheetname: Kate gisa kopiatuko den edo objektu gisa haren erreferentzia egingo den orriaren izena.

newname: Txertatuko den orriaren izena. Izenak dokumentuan erabili gabea izan behar du.

beforesheet: Orri baten izena (katea) edo indizea (zenbakizkoa, 1 zenbakitik hasita). Kopiatutako orria orri honen aurretik txertatuko da. Argumentu hau aukerakoa da eta portaera lehenetsia kopiatutako orria azken posizioan gehitzea da.

Adibidea:

Basic lengoaian

Hurrengo adibidez "SheetX" orriaren kopia bat egiten du eta uneko dokumentuaren azken orri gisa kokatzen du. Kopiatutako orriaren izena "SheetY" da.


    Dim oDoc as Object
    'Leiho aktiboaren dokumentu-objektua eskuratzen du
    Set oDoc = CreateScriptService("Calc")
    oDoc.CopySheet("SheetX", "SheetY")
  

Beheko adibideak "SheetX" kopiatzen du "FileA.ods" fitxategitik eta "FileB.ods" fitxategiaren azken posizioan kopiatzen du "SheetY" izenarekin:


      Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
      Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
      oDocB.CopySheet(oDocA.Sheet("SheetX"), "SheetY")
  
Python lengoaian

    myDoc.CopySheet("SheetX", "SheetY")
  

    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopySheet(docA.Sheet("SheetX"), "SheetY")
  
tip

Dokumentu irekien arteko orriak kopiatzeko, erabili CopySheet. Orriak Itxita dauden dokumentuen arten kopiatzeko, erabili CopySheetFromFile.


CopySheetFromFile

Itxitako Calc dokumentu bateko orri jakin bat kopiatzen du eta Document objektu batek erreferentzia egiten dion fitxategiak duen orri baten aurretik edo orri-zerrendaren amaieran itsasten du.

Fitxategia existitzen ez bada, errore bat gertatuko da. Fitxategia ez bada baliozko Calc fitxategia, orri zuria txertatuko da. Iturburuko orria existitzen ez bada sarrerako fitxategian, errore-mezu bat txertatuko da itsatsi berri den orriaren goiko aldean.

Sintaxia:

svc.CopySheetFromFile(filename: str, sheetname: str, newname: str, [beforesheet: any]): bool

Parametroak:

filename: Irekiko den fitxategia identifikatzen du. SF_FileSystem.FileNaming notazioa jarraitu behar du. Fitxategiak ez du pasahitzarekin babestuta egon behar.

OrriIzena: Kate gisa kopiatuko den orriaren izena.

newname: Dokumentuan txertatuko den kopiatutako orriaren izena. Izenak ez du dokumentuan erabilia izan behar.

beforesheet: Kopiatutako orria zein orriren aurretik txertatuko den. Bigarren orri horren izena (katea) edo indizea (zenbakia, 1 zenbakitik hasita) izan daiteke. Argumentu hau aukerakoa da eta portaera lehenetsia da kopiatutako orria azken posizioan kopiatzea.

Adibidea:

Hurrengo adibideak "myFile.ods" fitxategiko "SheetX" orria kopiatzen du eta "oDoc" aldagaiak "SheetY" gisa erreferentziatuta duen dokumentuan itsasten du, lehen posizioan.

Basic lengoaian

    oDoc.CopySheetFromFile("C:\Documents\myFile.ods", "SheetX", "SheetY", 1)
  
Python lengoaian

    myDoc.CopySheetFromFile(r"C:\Documents\myFile.ods", "SheetX", "SheetY", 1)
  

CopyToCell

Zehaztutako iturburuko barruti bat (balioak, formulak eta formatuak) helburuko barruti edo gelaxka batean kopiatzen du. Metodoak kopiatu/itsatsi portaera errepikatzen du barrutik batetik gelaxka bakarrera.

Aldatutako gelaxka-barrutia ordezkatzen duen kate bat itzultzen du. Aldatutako arearen tamaina iturburuko arearen tamainak zehazten du.

Iturburu-barrutia beste dokumentu ireki batekoa izan daiteke.

Sintaxia:

svc.CopyToCell(sourcerange: any, destinationcell: str): str

Parametroak:

sourcerange: Iturburu-barrutia kate gisa, dokumentu berekoa denean, edo erreferentzia gisa, beste Calc dokumentu batekoa denean.

destinationcell: Kopiatutako gelaxka-barrutia itsatsiko den helburuko gelaxka, kate gisa. Barruti bat ematen bada, goiko ezkerreko gelaxka soilik hartuko da kontuan.

Adibidea:

Basic lengoaian

Hurrengo adibidean, iturburua eta helburua fitxategi berean daude:


      oDoc.CopyToCell("SheetX.A1:F10", "SheetY.C5")
  

Beheko adibideak erakusten du nola kopiatu barruti bat beste Calc dokumentu ireki batean:


    Dim ui as Variant : ui = CreateScriptService("UI")
    Dim oDocSource As Object, oDocDestination As Object
    'Ireki iturburu-dokumentua atzeko planoan (ezkutuan)
    Set oDocSource = ui.OpenDocument("C:\SourceFile.ods", Hidden := True, ReadOnly := True)
    Set oDocDestination = CreateScriptService("Calc")
    oDocDestination.CopyToCell(oDocSource.Range("Sheet1.C2:C4"), "SheetT.A5")
    'Ez ahaztu iturburu-dokumentua ixtea, ezkutuan ireki baita
    oDocSource.CloseDocument()
  
Python lengoaian

    docSource = ui.OpenDocument(r"C:\Documents\SourceFile.ods", hidden = True, readonly = True)
    docDestination = CreateScriptService("Calc")
    docDestination.CopyToCell(docSource.Range("Sheet1.C2:C4"), "SheetT.A5")
    docSource.CloseDocument()
  
tip

Barruti batetik gelaxka bakar batera kopiatuko/itsatsiko dela simulatzeko, erabili CopyToCell. Barruti batetik barruti handiago batera kopiatuko/itsatsiko dela (gelaxka berak hainbatetan bikoiztuta) simulatzeko, erabili CopyToRange.


CopyToRange

Beherantz eta/edo eskuinerantz kopiatzen du iturburu-barruti zehatz bat (balioak, formulak eta formatuak) helburuko barruti batean. Metodo horrek iturburu-barruti batetik helburuko barruti handiago batean kopiatzeko/itsasteko eragiketaren portaera imitatzen du.

Metodoak gelaxka-barruti aldatua ordezkatzen duen kate bat itzultzen du.

Iturburuko barrutia irekitako beste dokumentu batetik etorri daiteke.

Sintaxia:

svc.CopyToRange(sourcerange: any, destinationrange: str): str

Parametroak:

sourcerange: Iturburu-barrutia kate gisa, dokumentu berekoa bada, edo erreferentzia gisa, irekita dagoen beste Calc dokumentu bateko bada.

destinationrange: Kopiatutako gelaxka-barrutien helburua, kate gisa.

Adibidea:

Basic lengoaian

Kopiatu dokumentu berearen barruan:


    oDoc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5")
    ' Barruti-kate bat itzultzen du: "$OrriaY.$C$5:$J$14"
  

Kopiatu fitxategi batetik beste batera:


    Dim oDocA As Object : Set oDocA = ui.OpenDocument("C:\Documents\FileA.ods", Hidden := True, ReadOnly := True)
    Dim oDocB As Object : Set oDocB = ui.OpenDocument("C:\Documents\FileB.ods")
    oDocB.CopyToRange(oDocA.Range("SheetX.A1:F10"), "SheetY.C5:J5")
  
Python lengoaian

    doc.CopyToRange("SheetX.A1:F10", "SheetY.C5:J5")
  

    docA = ui.OpenDocument(r"C:\Documents\FileA.ods", hidden = True, readonly = True)
    docB = ui.OpenDocument(r"C:\Documents\FileB.ods")
    docB.CopyToRange(docA.Range("SheetX.A1:F10"), "SheetY.C5:J5")
  

CreateChart

Creates a new chart object showing the data in the specified range. The returned chart object can be further manipulated using the Chart service.

Sintaxia:

svc.CreateChart(chartname: str, sheetname: str, range: str, columnheader: bool = False, rowheader: bool = False): obj

Parametroak:

chartname: The user-defined name of the chart to be created. The name must be unique in the same sheet.

sheetname: The name of the sheet where the chart will be placed.

range: The range to be used as the data source for the chart. The range may refer to any sheet of the Calc document.

columnheader: When True, the topmost row of the range is used as labels for the category axis or the legend (Default = False).

rowheader: When True, the leftmost column of the range is used as labels for the category axis or the legend. (Default = False).

Adibidea:

The examples below in Basic and Python create a chart using the data contained in the range "A1:B5" of "Sheet1" and place the chart in "Sheet2".

Basic lengoaian

    Set oChart = oDoc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", RowHeader := True)
    oChart.ChartType = "Donut"
  
Python lengoaian

    chart = doc.CreateChart("MyChart", "Sheet2", "Sheet1.A1:B5", rowheader=True)
    chart.ChartType = "Donut"
  
tip

Refer to the help page about ScriptForge's Chart service to learn more how to further manipulate chart objects. It is possible to change properties as the chart type, chart and axes titles and chart position.


DAvg, DCount, DMax, DMin and DSum

Aplikatu Average, Count, Max, Min eta Sum, hurrenez hurren, emandako barruti batean zenbakizko balioak dituzten gelaxka guztiei.

Sintaxia:

svc.DAvg(range: str): float

svc.DCount(range: str): float

svc.DMax(range: str): float

svc.DMin(range: str): float

svc.DSum(range: str): float

Parametroak:

range: Funtzioa aplikatuko zaion barrutia, kate gisa.

Adibidea:

Beheko adibidean Sum funtzioa aplikatzen zaio unean hautatutako orriko "A1:A1000" barrutiari:

Basic lengoaian

      result = oDoc.DSum("~.A1:A1000")
  
Python lengoaian

    result = myDoc.DSum("~.A1:A1000")
  
note

Emandako barrutian, testua duten gelaxkei ez ikusiarena egingo diete funtzio horiek. Adibidez, DCount metodoak ez ditu zenbatuko testua duten gelaxkak, zenbakiak dituztenak soilik.


Forms

Emandako parametroen arabera, metodoak honakoa itzuliko du:

Sintaxia:

svc.Forms(sheetname: str): str[0..*]

svc.Forms(sheetname: str, form: str = ''): svc

svc.Forms(sheetname: str, form: int): svc

Parametroak:

sheetname: Orri baten izena, kate gisa, zeinetatik inprimakia atzituko den.

form: Zehaztutako orrian biltegiratutako inprimaki baten izena edo hari dagokion indizea. Argumentu hau falta bada, metodoak orrian eskuragarri dauden inprimaki guztien izenak dituen zerrenda bat itzuliko du.

Adibidea:

Hurrengo adibideetan, lehen lerroak "Orria1" orrian biltegiratutako inprimaki guztien izenak jasotzen ditu eta bigarren lerroak "Orria1" orrian dagoen "Inp_A" izeneko inprimakiaren Form objektua atzitzen du.

Basic lengoaian

    Set FormNames = oDoc.Forms("Sheet1")
    Set FormA = oDoc.Forms("Sheet1", "Form_A")
  
Python lengoaian

    form_names = doc.Forms("Sheet1")
    form_A = doc.Forms("Sheet1", "Form_A")
  

GetColumnName

1 eta 1024 zenbakien artean dagoen zutabe-zenbaki bat zenbakiari dagokion letra ('A', 'B', ..., 'AMJ' zutabea) bihurtzen du. Emandako zutabe-zenbakia onartutako barrutitik at badago, zero luzerako kate bat itzuliko da.

Sintaxia:

svc.GetColumnName(columnnumber: int): str

Parametroak:

columnnumber: Zutabe-zenbakia 1 ... 1024 tarteko osoko balio gisa.

Adibidea:

Basic lengoaian

Hirugarren zutabearen izena duen mezu-koadro bat bistaratzen du. Modu lehenetsian "C" da izena.


    MsgBox oDoc.GetColumnName(3)
  
Python lengoaian

    bas = CreateScriptService("Basic")
    bas.MsgBox(myDoc.GetColumnName(3))
  
note

Calc orri batean onartzen den gehieneko zutabe kopurua 1024 da.


GetFormula

Eskuratu emandako gelaxka-barrutian gordetako formula(k) kate bakar gisa edo 1D edo 2D kate-matrize gisa.

Sintaxia:

svc.GetFormula(range: str): any

Parametroak:

range: Formulak zein barrutitik eskuratuko diren, kate gisa.

Adibidea:

Basic lengoaian

Hurrengo adibideak 3 x 2 matrize bat itzultzen du, "A1:B3" barrutiko formulak hartuta (3 errenkada x 2 zutabe):


    arrFormula = oDoc.GetFormula("~.A1:B3")
  
Python lengoaian

    arrFormula = myDoc.GetFormula("~.A1:B3")
  

GetValue

Eskuratu emandako gelaxka-barrutian gordetako balio(k) kate bakar gisa edo 1D edo 2D kate-matrize gisa. Balio guztiak zenbaki bikoitiak edo kateak dira.

Sintaxia:

svc.GetValue(range: str): any

Parametroak:

range: Balioak zein barrutitik eskuratuko diren, kate gisa.

Adibidea:

Basic lengoaian

      arrValues = oDoc.GetValue("~.B1:C100")
  
Python lengoaian

    arrValues = myDoc.GetValue("~.B1:C100")
  
note

Gelaxka batek data bat badu, data horri dagokion zenbakia itzuliko da. Zenbakizko balioak data bihurtzeko Basic scriptetan, erabili CDate funtzio integratua. Python scriptetan, erabili Basic zerbitzuaren CDate funtzioa.


ImportFromCSVFile

CSV formatuko testu-fitxategi bateko edukiak inportatzen ditu eta emandako helburuko gelaxkan kokatzen ditu.

Helburuko areako eduki eta formatu guztiak garbitzen dira CSV fitxategiaren edukiak txertatu baino lehen. Aldatutako arearen tamaina sarrerako fitxategiko edukien araberakoa da.

Metodoak gelaxka-barruti aldatua ordezkatzen duen kate bat itzultzen du.

Sintaxia:

svc.ImportFromCSVFile(filename: str, destinationcell: str, [filteroptions: str]): str

Parametroak:

filename: Irekiko den fitxategia identifikatzen du. SF_FileSystem.FileNaming notazioa jarraitu behar du.

destinationcell: Inportatutako datuak txertatuko diren helburuko gelaxka, kate gisa. Barruti bat ematen bada, goiko ezkerreko gelaxka soilik hartuko da kontuan.

filteroptions: Sarrerako CSV fitxategiaren argumentuak. Iragazki lehenetsiak honako baldintzak ematen ditu ontzat:

Adibidea:

Basic lengoaian

    oDoc.ImportFromCSVFile("C:\Temp\myCSVFile.csv", "SheetY.C5")
  
Python lengoaian

    myDoc.ImportFromCSVFile(r"C:\Temp\myCSVFile.csv", "SheetY.C5")
  
tip

CSV iragazkiaren aukerak ezagutzeko, begiratu iragazki-aukerei buruzko wikiko orria.


ImportFromDatabase

Datu-base bateko taula, kontsulta edo emaitza multzo baten edukiak inportatzen ditu, alegia SELECT SQL komandoaren emaitza, eta helburuko gelaxka batean txertatzen du.

Helburuko areako eduki eta formatu guztiak garbituko dira inportatutako edukiak txertatu baino lehen. Aldatutako arearen tamaina taulako edo kontsultako edukien araberakoa izango da.

Metodo honek True itzultzen du inportazioa ongi gauzatu denean.

Sintaxia:

svc.ImportFromDatabase(filename: str = "", registrationname: str = "", destinationcell: str = "", sqlcommand: str = "", directsql: bool): bool

Parametroak:

filename: Irekiko den fitxategia identifikatzen du. SF_FileSystem.FileNaming notazioa jarraitu behar du.

registrationname: Datu-baseen erregistroan datu-basea aurkitzeko erabiliko den izena. Argumentu honi ez ikusiarena egingo zaio filename ematen bada.

destinationcell: Inportatutako datuen helburua, kate gisa. Barruti bat ematen bada, goiko ezkerreko gelaxka soilik hartuko da kontuan.

sqlcommand: Taula baten edo kontsulta baten izena (inguruan komatxoak edo kortxeteak jarri gabe) edo SELECT SQL instrukzio bat non taularen edo eremuen izenak kortxeteekin edo komatxoekin inguratuta egon daitezkeen instrukzioaren irakurgarritasuna hobetzeko.

directsql: True (egia) denean, SQL komandoa aurretiko analisirik gabe bidaltzen zaio datu-basearen motorrari. Balio lehenetsia False (faltsua) da. Taulen kasuan, ez ikusiarena egiten zaio argumentuari. Kontsultetan, aplikatutako aukera kontsulta definitu zenean ezarritakoa da.

Adibidea:

Basic lengoaian

    oDoc.ImportFromDatabase("C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]")
  
Python lengoaian

    myDoc.ImportFromDatabase(r"C:\Temp\myDbFile.odb", , "SheetY.C5", "SELECT * FROM [Employees] ORDER BY [LastName]")
  

InsertSheet

Orri huts berria txertatzen du lehendik dagoen orri baten aurrean edo orrien zerrendaren amaieran.

Sintaxia:

svc.InsertSheet(sheetname: str, [beforesheet: any]): bool

Parametroak:

sheetname: Orri berriaren izena.

beforesheet: Orri berria argumentu honetan ezarritako orriaren aurrean txertatuko da. Orriaren izena (katea) edo indizea (zenbakia, 1etik hasita) eman behar da. Argumentu hau aukerakoa da, portaera lehenetsian orria azken posizioan txertatuko da.

Adibidea:

Hurrengo adibideak "SheetX" izeneko orri hutsa txertatzen du eta "SheetY" orriaren aurrean kokatzen du:

Basic lengoaian

    oDoc.InsertSheet("SheetX", "SheetY")
  
Python lengoaian

    myDoc.InsertSheet("SheetX", "SheetY")
  

MoveRange

Iturburko barruti bat helburuko gelaxka-barruti batera eramaten du. Metodoak gelaxka-barruti aldatua ordezkatzen duen kate bat itzultzen du. Aldatutako arearen dimentsioak iturburuko arearen tamainaren arabera zehazten dira.

Sintaxia:

svc.MoveRange(source: str, destination: str): str

Parametroak:

source: Gelaxken iturburu-barrutia, kate gisa.

destination: Helburuko gelaxka, kate gisa. Barruti bat ematen bada, goiko ezkerreko gelaxka hartuko da helburutzat.

Adibidea:

Basic lengoaian

    oDoc.MoveRange("SheetX.A1:F10", "SheetY.C5")
  
Python lengoaian

    myDoc.MoveRange("SheetX.A1:F10", "SheetY.C5")
  

MoveSheet

Lehendik dagoen orri bat lekuz aldatzen du eta zehaztutako orri baten aurrean edo orri-zerrendaren amaieran kokatzen du.

Sintaxia:

svc.MoveSheet(sheetname: str, [beforesheet: any]): bool

Parametroak:

sheetname: Lekuz aldatuko den orriaren izena. Orriak existitu behar du, bestela salbuespen bat sortuko da.

beforesheet : Jatorrizko orria zein orriren aurretik txertatuko den. Bigarren orri horren izena (katea) edo indizea (zenbakia, 1etik hasita) eman daiteke. Argumentu hau aukerakoa da eta portaera lehenetsia da orria azken posiziora eramatea.

Adibidea:

Beheko adibideak lehendik dagoen "SheetX" lekuz aldatzen du eta "SheetY" aurrean kokatzen du:

Basic lengoaian

    oDoc.MoveSheet("SheetX", "SheetY")
  
Python lengoaian

    myDoc.MoveSheet("SheetX", "SheetY")
  

Offset

Barruti-desplazamendu berri bat itzultzen du (kate gisa). Desplazamendua errenkada eta zutabe kopuru jakin batekoa da, emandako barruti batetik.

Metodo honek Calc aplikazioko izen bereko Offset funtzioaren portaera bera du.

Sintaxia:

svc.Offset(reference: str, rows: int = 0, columns: int = 0, [height: int], [width: int]): str

Parametroak:

reference: Desplazamendua gauzatzeko metodoak erreferentzia modura erabiliko duen barrutia, kate gisa.

rows: Hasierako barrutia gorantz (balio negatiboa) edo beherantz (balio positiboa) desplazatuko den errenkada kopurua. Erabili 0 (balio lehenetsia) errenkada berean geratzeko.

columns: Hasierako barrutia ezkerrerantz (balio negatiboa) edo eskuinerantz (balio positiboa) desplazatuko den zutabe kopurua. Erabili 0 (balio lehenetsia) zutabe berean geratzeko.

height: Barruti-kokaleku berrian hasten den area baten altuera bertikala. Ez erabili argumentu hau tamaina bertikala aldatu behar ez denean.

width: Barruti-kokaleku berrian hasten den area baten zabalera horizontala. Ez erabili argumentu hau tamaina horizontala aldatu behar ez denean.

rows eta columns argumentuek ez dute zero edo negatiboa den hasierako errenkada edo zutabera eraman behar.

height eta width argumentuek ez dute zero edo negatiboa den errenkada edo zutabeen kopurua eman behar.

Adibidea:

Basic lengoaian

    oDoc.Offset("A1", 2, 2)
    'SheetX.$C$3 (A1 gelaxka bi errenkada eta bi zutabe beherantz eraman da)
    oDoc.Offset("A1", 2, 2, 5, 6)
    'SheetX.$C$3:$H$7 (A1 gelaxka bi errenkada eta zutabe lekuz aldatu da, 5 errenkadako eta 6 zutabeko zabalerarekin)
  
Python lengoaian

    myDoc.Offset("A1", 2, 2)
    myDoc.Offset("A1", 2, 2, 5, 6)
  

OpenRangeSelector

Opens a non-modal dialog that can be used to select a range in the document and returns a string containing the selected range.

note

This method opens the same dialog that is used by LibreOffice when the Shrink button is pressed. For example, the Tools - Goal Seek dialog has a Shrink button to the right of the Formula cell field.


This method does not change the current selection.

Sintaxia:

svc.OpenRangeSelector(opt title: str, opt selection: str, singlecell: bool = False, closeafterselect: bool = True): str

Parametroak:

title: The title of the dialog, as a string.

selection: An optional range that is initially selected when the dialog is displayed.

singlecell: When True (default) only single-cell selection is allowed. When False range selection is allowed.

closeafterselect: When True (default) the dialog is closed immediately after the selection is made. When False the user can change the selection as many times as needed and then manually close the dialog.

Adibidea:

Basic lengoaian

    Dim sRange as String
    sRange = oDoc.OpenRangeSelector(Title := "Select a range")
  
Python lengoaian

    sRange = myDoc.OpenRangeSelector(title = "Select a range")
  

Printf

Returns the input string after substituting its token characters by their values in a given range.

This method does not change the current selection.

tip

This method can be used to quickly extract specific parts of a range name, such as the sheet name or first cell column and row, and use them to compose a new range address.


Sintaxia:

svc.Printf(inputstr: str, range: str, tokencharacter: str = "%"): str

Parametroak:

inputstr: The string containing the tokens that will be replaced by the corresponding values in range.

range: A RangeName from which values will be extracted. If it contains a sheet name, the sheet must exist.

tokencharacter: Character used to identify tokens. By default "%" is the token character. The following tokens are accepted:

Adibidea:

Basic lengoaian

The example below extracts each element of the RangeName defined in sRange and uses them to compose a message.


    Dim sRange as String, sInputStr as String
    sRange = "Sheet1.A1:E10"
    sInputStr = "Sheet name: %S" & Chr(10) & _
                "First row: %R1" & Chr(10) & _
                "First column %C1" & Chr(10) & _
                "Last row %R2" & Chr(10) & _
                "Last column %C2"
    MsgBox oDoc.Printf(sInputStr, sRange)
  

The Printf method can be combined with SetFormula to create formulas over multiple cells. For instance, consider a table with numeric values in the range "A1:E10" from which formulas are to be created to sum the values in each row and place the results in the range "F1:F10":


    Dim sFormula as String, sRange as String
    sRange = "A1:E10"
    ' Note the use of the "$" character
    sFormula = "=SUM($%C1%R1:$%C2%R1)"
    oDoc.SetFormula("F1:F10", oDoc.Printf(sFormula, sRange))
  
Python lengoaian

    sRange = "Sheet1.A1:E10"
    sInputStr = "Sheet name: %S\n" \
                "First row: %R1\n" \
                "First column %C1\n" \
                "Last row %R2\n" \
                "Last column %C2"
    bas = CreateScriptService("Basic")
    bas.MsgBox(myDoc.Printf(sInputStr, sRange))
  

    sRange = "A1:E10
    sFormula = "=SUM($%C1%R1:$%C2%R1)"
    myDoc.SetFormula("F1:F10", myDoc.Printf(sFormula, sRange))
  

PrintOut

This method sends the contents of the given sheet to the default printer or to the printer defined by the SetPrinter method of the Document service.

Returns True if the sheet was successfully printed.

Sintaxia:

svc.PrintOut(opt sheetname: str, pages: str = "", copies: num = 1): bool

Parametroak:

sheetname: The sheet to print, default is the active sheet.

pages: The pages to print as a string, like in the user interface. Example: "1-4;10;15-18". Default is all pages.

copies: The number of copies. Default is 1.

Adibidea:

Basic lengoaian

    If oDoc.PrintOut("SheetX", "1-4;10;15-18", Copies := 2) Then
        ' ...
    End If
  
Python lengoaian

    if doc.PrintOut('SheetX', copies=3, pages='45-88'):
        # ...
  

RemoveSheet

Lehendik dagoen orri bat dokumentutik kentzen du.

Sintaxia:

svc.RemoveSheet(sheetname: str): bool

Parametroak:

OrriIzena: Kenduko den orriaren izena.

Adibidea:

Basic lengoaian

    oDoc.RemoveSheet("SheetY")
  
Python lengoaian

    myDoc.RemoveSheet("SheetY")
  

RenameSheet

Emandako orriaren izena aldatzen du eta True itzultzen du ongi aldatzen badu.

Sintaxia:

svc.RenameSheet(sheetname: str, newname: str): bool

Parametroak:

sheetname: Izena aldatuko zaion orriaren izena.

newname: Orriaren izen berria. Lehendik ez du izen horrek egon behar.

Adibidea:

Adibide honetan, orri aktiboari "SheetY" izena ematen zaio:

Basic lengoaian

    oDoc.RenameSheet("~", "SheetY")
  
Python lengoaian

    mydoc.RenameSheet("~", "SheetY")
  

SetArray

Emandako balioa biltegiratzen du, zehaztutako helburuko gelaxka batean hasita. Eguneratutako area hedatu egingo da helburuko gelaxkatik edo emandako barrutiaren goiko ezkerreko izkinatik, sarrerako value argumentuaren tamainari egokitzeko. Bektoreak bertikalean hedatuko dira beti.

Metodoak area aldatua gelaxka-barruti gisa ordezkatzen duen kate bat itzultzen du.

Sintaxia:

svc.SetArray(targetcell: str, value: any): str

Parametroak:

targetcell: Emandako balioa biltegiratzen hasiko den gelaxka edo barrutia (kate gisa).

value: Eskalar bat, bektore bat edo matrize bat (Python lengoiaian, dimentsio bateko edo biko zerrendak eta tuplak), biltegiratuko diren balio berriak dituena. Balioak helburuko gelaxkan hasita edo barrutiaren goiko ezkerreko izkinan hasita, targetcell barruti bat bada, biltegiratuko dira. Balio berriek kateak, zenbakizko balioak edo datak izan behar dute. Beste motak erabiltzen badira, gelaxkak hustu egingo dira.

Adibidea:

Basic lengoaian

Hurrengo adibideak DimArray funtzioa integratua darabil matrize bat sortzeko eta hura "A1" gelaxkan biltegiratzeko:


    Dim arrData as Variant
    arrData = DimArray(2, 1)
    arrData(0, 0) = 1 : arrData(1, 0) = 2 : arrData(2, 0) = 3
    arrData(0, 1) = "One" : arrData(1, 1) = "Two" : arrData(2, 1) = "Three"
    oDoc.SetArray("Sheet1.A1", arrData)
  

Adibide honek ScriptForge Array zerbitzuaren RangeInit metodoa darabil matrize bat sortu eta, ondoren, matrizeko balioak "A1" gelaxkan eta haren azpikoetan biltegiratzeko.


    'Bete lehen zutabea 1 eta 1000 arteko balioekin
    oDoc.SetArray("Sheet1.A1", SF_Array.RangeInit(1, 1000))
  
Python lengoaian

    arrData = ((1, "One"), (2, "Two"), (3, "Three"))
    myDoc.SetArray("Sheet1.A1", arrData)
  

    myDoc.SetArray("Sheet1.A1", tuple(i + 1 for i in range(1000)))
  
tip

Matrize baten eduki osoa orri batean isurtzeko, erabili SetArray. Matrize baten edukiak helburuko gelaxka-barrutian soilik isurtzeko, erabili SetValue.


SetValue

Emandako balioa zehaztutako barrutian biltegiratzen du. Aldatutako arearen tamaina helburuko barrutiaren tamaina bera izango da.

Metodoak area aldatua gelaxka-barruti gisa ordezkatzen duen kate bat itzultzen du.

Sintaxia:

svc.SetValue(targetrange: str, value: any): str

Parametroak:

targetrange: Emandako balioa biltegiratuko den barrutia, kate gisa.

value: Eskalar bat, bektore bat edo matrize bat, barrutiko gelaxka bakoitzerako balio berriak dituena. Balio berriek kateak, zenbakizko balioak edo datak izan behar dute. Beste motak erabiltzen badira, gelaxkak hustu egingo dira.

Barruti osoa eguneratuko da eta orriaren gainerakoa aldaketarik gabe mantenduko da. value balioaren tamaina targetrange balioarena baino txikiagoa bada, gainerako gelaxkak hustu egingo dira.

value balioaren tamaina targetrange balioarena baino handiagoa bada, orduan value partzialki soilik kopiatuko da targetrange elementuaren tamaina bete arte.

Bektoreak bertikalean hedatzen dira, salbu eta targetrange parametroak errenkada bakar bateko altuera badu.

Adibidea:

Basic lengoaian

    oDoc.SetValue("A1", 2)
    'Behean, Value matrizea TargetRange baino txikiagoa da (gainerako gelaxkak hustu egingo dira)
    oDoc.SetValue("A1:F1", Array(1, 2, 3))
    'Behean, Value eta TargetRange barrutiek tamaina bera dute
    oDoc.SetValue("A1:D2", SF_Array.AppendRow(Array(1, 2, 3, 4), Array(5, 6, 7, 8)))
  

Errenkada bakarra balioekin bete nahi izanez gero, Offset funtzioa erabili daiteke. Beheko adibidean, kontuan hartu arrData dimentsio bakarreko matrizea dela:


    Dim firstCell As String : firstCell = "A1"
    Dim lenArray As Integer : lenArray = UBound(arrData) - LBound(arrData) + 1
    Dim newRange As String : newRange = oDoc.Offset(firstCell, width = lenArray)
    oDoc.SetValue(newRange, arrData)
  
Python lengoaian

    myDoc.SetValue("A1", 2)
    myDoc.SetValue("A1:F1", (1, 2, 3))
    myDoc.SetValue("A1:D2", ((1, 2, 3, 4), (5, 6, 7, 8)))
  

    firstCell = "A1"
    newRange = doc.Offset(firstCell, width = len(arrData))
    doc.SetValue(newRange, arrData)
  

SetCellStyle

Zehaztutako gelaxka-estiloa emandako helburuko barrutiari aplikatzen dio. Barruti osoa eguneratuko da eta orriaren gainerakoa ez da ukituko. Gelaxka-estiloa existitzen ez bada, errore bat sortuko da.

Aldatutako area gelaxken barruti gisa adierazten duen kate bat itzultzen du metodoak.

Sintaxia:

svc.SetCellStyle(targetrange: str, style: str): str

Parametroak:

targetrange: Estiloa aplikatuko zaion barrutia, kate gisa.

style: Aplikatuko den gelaxka-estiloaren izena.

Adibidea:

Basic lengoaian

    oDoc.SetCellStyle("A1:J1", "Heading 1")
    oDoc.SetCellStyle("A2:J100", "Neutral")
  
Python lengoaian

    myDoc.SetCellStyle("A1:J1", "Heading 1")
    myDoc.SetCellStyle("A2:J100", "Neutral")
  

SetFormula

Emandako formulen (matrizea) zehaztutako barrutian txertatzen du. Aldatutako arearen tamaina eta barrutiaren tamaina berdinak dira.

Aldatutako area gelaxken barruti gisa adierazten duen kate bat itzultzen du metodoak.

Sintaxia:

svc.SetFormula(targetrange: str, formula: any): str

Parametroak:

targetrange: Formulak txertatuko diren barrutia, kate gisa.

formula: Helburuko barrutiko gelaxka bakoitzerako formula berriak dituen kate bat, bektore bat edo kateen matrize bat.

Barruti osoa eguneratuko da eta orriaren gainerakoa aldaketarik gabe utziko da.

Emandako formula kate bat bada, formula bakarra barruti osoan itsatsiko da, erreferentzia erlatiboak doituta.

formula barrutiaren tamaina targetrange barrutiarena baino txikiagoa bada, gainerako gelaxkak hustu egingo dira.

formula barrutiaren tamaina targetrange barrutiarena baino handiagoa bada, formulak partzialki soilik kopiatuko dira targetrange barrutiaren tamaina bete arte.

Bektoreak bertikalean hedatzen dira beti, salbu eta targetrange barrutiaren altuera errenkada batekoa bada.

Adibidea:

Basic lengoaian

    oDoc.SetFormula("A1", "=A2")
    'Bektore horizontala, partzialki hutsik
    oDoc.SetFormula("A1:F1", Array("=A2", "=B2", "=C2+10"))
    'D2 gelaxkak "=H2" formula du
    oDoc.SetFormula("A1:D2", "=E1")
  
Python lengoaian

    myDoc.SetFormula("A1", "=A2")
    myDoc.SetFormula("A1:F1", ("=A2", "=B2", "=C2+10"))
    myDoc.SetFormula("A1:D2", "=E1")
  

ShiftDown

Moves a given range of cells downwards by inserting empty rows. The current selection is not affected.

Depending on the value of the wholerows argument the inserted rows can either span the width of the specified range or span all columns in the row.

This method returns a string representing the new location of the initial range.

note

If the shifted range exceeds the sheet edges, then nothing happens.


Sintaxia:

svc.ShiftDown(range: str, wholerow: bool = False, opt rows: int): str

Parametroak:

range: The range above which rows will be inserted, as a string.

wholerow: If set to False (default), then the width of the inserted rows will be the same as the width of the specified range. Otherwise, the inserted row will span all columns in the sheet.

rows: The number of rows to be inserted. The default value is the height of the original range. The number of rows must be a positive number.

Adibidea:

Basic lengoaian

    ' Moves the range "A3:D3" down by one row; affects only columns A to D
    oDoc.ShiftDown("A3:D3")
    ' The inserted row spans all columns in the sheet
    oDoc.ShiftDown("A3:D3", WholeRow := True)
    ' Moves the range "A3:D3" down by five rows
    oDoc.ShiftDown("A3:D3", Rows := 5)
    ' Moves the range "A3:D10" down by two rows and shows the new location of the original range
    Dim sNewRange as String
    sNewRange = oDoc.ShiftDown("A3:D10", Rows := 2)
    MsgBox sNewRange   ' $Sheet1.$A$5:$D$12
  
Python lengoaian

    myDoc.ShiftDown("A3:D3")
    myDoc.ShiftDown("A3:D3", wholerow = True)
    myDoc.ShiftDown("A3:D3", rows = 5)
    sNewRange = myDoc.ShiftDown("A3:D10", rows = 2)
    bas = CreateScriptService("Basic")
    bas.MsgBox(sNewRange)
  

ShiftLeft

Deletes the leftmost columns of a given range and moves to the left all cells to the right of the affected range. The current selection is not affected.

Depending on the value of the wholecolumns argument the deleted columns can either span the height of the specified range or span all rows in the column.

This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned.

Sintaxia:

svc.ShiftLeft(range: str, wholecolumn: bool = False, opt columns: int): str

Parametroak:

range: The range from which cells will be deleted, as a string.

wholecolumn: If set to False (default), then the height of the deleted columns will be the same as the height of the specified range. Otherwise, the deleted columns will span all rows in the sheet.

columns: The number of columns to be deleted from the specified range. The default value is the width of the original range, which is also the maximum value of this argument.

Adibidea:

Basic lengoaian

    ' Deletes the range "B3:B6"; moves left all cells to the right
    oDoc.ShiftLeft("B3:B6")
    ' Deletes the first column in the range "A3:D6"
    oDoc.ShiftLeft("A3:D6", Columns := 1)
    ' The deleted columns (A to D) spans all rows in the sheet
    oDoc.ShiftLeft("A3:D6", WholeColumn := True)
  
Python lengoaian

    myDoc.ShiftLeft("B3:B6")
    myDoc.ShiftLeft("A3:D6", Columns = 1)
    myDoc.ShiftLeft("A3:D6", WholeColumn = True)
  

ShiftUp

Deletes the topmost rows of a given range and moves upwards all cells below the affected range. The current selection is not affected.

Depending on the value of the wholerows argument the deleted rows can either span the width of the specified range or span all columns in the row.

This method returns a string representing the location of the remaining portion of the initial range. If all cells in the original range have been deleted, then an empty string is returned.

Sintaxia:

svc.ShiftUp(range: str, wholerow: bool = False, opt rows: int): str

Parametroak:

range: The range from which cells will be deleted, as a string.

wholerow: If set to False (default), then the width of the deleted rows will be the same as the width of the specified range. Otherwise, the deleted row will span all columns in the sheet.

rows: The number of rows to be deleted from the specified range. The default value is the height of the original range, which is also the maximum value of this argument.

Adibidea:

Basic lengoaian

    ' Deletes the range "A3:D3"; moves all cells below it by one row up
    oDoc.ShiftUp("A3:D3")
    ' Deletes the first row in the range "A3:D6"
    oDoc.ShiftUp("A3:D6", Rows := 1)
    ' The deleted rows spans all columns in the sheet
    oDoc.ShiftUp("A3:D6", WholeRow := True)
  
Python lengoaian

    myDoc.ShiftUp("A3:D3")
    myDoc.ShiftUp("A3:D6", rows = 1)
    myDoc.ShiftUp("A3:D6", wholerow = True)
  

ShiftRight

Moves a given range of cells to the right by inserting empty columns. The current selection is not affected.

Depending on the value of the wholecolumns argument the inserted columns can either span the height of the specified range or span all rows in the column.

This method returns a string representing the new location of the initial range.

note

If the shifted range exceeds the sheet edges, then nothing happens.


Sintaxia:

svc.ShiftRight(range: str, wholecolumn: bool = False, opt columns: int): str

Parametroak:

range: The range which will have empty columns inserted to its left, as a string.

wholecolumn: If set to False (default), then the height of the inserted columns will be the same as the height of the specified range. Otherwise, the inserted columns will span all rows in the sheet.

columns: The number of columns to be inserted. The default value is the width of the original range.

Adibidea:

Basic lengoaian

    ' Moves the range "A3:A6" right by one column; affects only rows 3 to 6
    oDoc.ShiftRight("A3:A6")
    ' Moves the range "A3:A6" right by five columns
    oDoc.ShiftRight("A3:A6", Columns := 5)
    ' The inserted column spans all rows in the sheet
    oDoc.ShiftRight("A3:A6", WholeColumn := True)
  
Python lengoaian

    myDoc.ShiftRight("A3:A6")
    myDoc.ShiftRight("A3:A6", columns = 5)
    myDoc.ShiftRight("A3:A6", wholecolumn = True)
  

SortRange

Emandako barrutia 1, 2 edo 3 zutabe/errenkadaren arabera ordenatzen du. Ordenatzea aldakorra izan daiteke zutabearen/errenkadaren arabera. Aldatutako gelaxka-barruti bat ordezkatzen duen kate bat itzultzen du. Aldatutako arearen tamaina iturburuko arearen tamainak zehazten du.

Sintaxia:

svc.SortRange(range: str, sortkeys: any, sortorder: any = "ASC", destinationcell: str = "", containsheader: bool = False, casesensitive: bool = False, sortcolumns: bool = False): str

Parametroak:

range: Ordenatuko den barrutia, kate gisa.

sortkeys: Eskalar bat (zutabe/errenkada bat erabiltzen bada) edo zutabeen/errenkaden matrize bat, bat baino gehiago erabiltzen bada. Gehieneko gako kopurua 3 da.

sortorder: "ASC" (gorantz), "DESC" (beherantz) edo "" (lehenetsia, gorantz da) balioak dituen eskalar bat edo kateen matrize bat. Elementu bakoitza sortkeys parametroan dagokion elementuarekin parekatuta dago. sortorder matrizea sortkeys baino laburragoa bada, gainerako gakoak gorantz ordenatuko dira.

destinationcell: Ordenatutako gelaxka-barrutiaren helburuko gelaxka, kate gisa. Barruti bat ematen bada, goiko ezkerreko gelaxka soilik erabiliko da. Modu lehenetsian, iturburuko barrutia gainidatzi egingo da.

containsheader: True bada, lehen errenkada/zutabea ez da ordenatuko.

casesensitive: Kate-konparazioetarako soilik. Balio lehenetsia = False

sortcolumns: True (egia) bada, zutabeak ezkerretik eskuinera ordenatuko dira. Balio lehenetsia = False (faltsua): errenkadak goitik behera ordenatuko dira.

Adibidea:

Basic lengoaian

    'Ordenatu barrutia A zutabean (gorantz) eta C zutabean (beherantz) oinarrituta
    oDoc.SortRange("A2:J200", Array(1, 3), Array("ASC", "DESC"), CaseSensitive := True)
  
Python lengoaian

    myDoc.SortRange("A2:J200", (1, 3), ("ASC", "DESC"), casesensitive = True)
  
warning

Azpimarraren karaktere bat, "_", aurrizki gisa duten ScriptForge Basic errutina edo identifikatzaile guztiak barneko erabilerarako erreserbatuta daude. Ez dira Basic makroetan edo Python scriptetan erabili behar.