LibreOffice Basic - Objecten: verschil tussen versies
Regel 1: | Regel 1: | ||
''Dit artikel is vooral bedoeld als referentie. Daarom bronnen gelijk in de afzonderlijke hoofdstukken opnemen.'' | ''Dit artikel is vooral bedoeld als referentie. Daarom bronnen gelijk in de afzonderlijke hoofdstukken opnemen.'' | ||
+ | |||
+ | == collapseToMergedArea() == | ||
+ | |||
+ | ''' Beschrijving ''' | ||
+ | |||
+ | [https://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSheetCellCursor.html#collapseToMergedArea]: | ||
+ | |||
+ | * Expands the cursor to merged cell ranges. | ||
+ | * Expands the current cursor range in a way so that all merged cell ranges intersecting the current range will fit completely. If the cursor does not point to any range with merged cells, it is left unchanged. | ||
+ | |||
+ | |||
+ | ''' Bronnen ''' | ||
+ | |||
+ | * https://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSheetCellCursor.html#collapseToMergedArea | ||
== copyByName() == | == copyByName() == |
Versie van 5 nov 2019 15:49
Dit artikel is vooral bedoeld als referentie. Daarom bronnen gelijk in de afzonderlijke hoofdstukken opnemen.
collapseToMergedArea()
Beschrijving
[1]:
- Expands the cursor to merged cell ranges.
- Expands the current cursor range in a way so that all merged cell ranges intersecting the current range will fit completely. If the cursor does not point to any range with merged cells, it is left unchanged.
Bronnen
copyByName()
copyByName
is een method van sheets.
Syntaxis
void copyByName ( [in] string aName, [in] string aCopy, [in] short nDestination ) * aName: Name of the sheet to be copied * aCopy: Name of the copied sheet * nDestination: Numerical index of the new sheet
Voorbeeld
Sub CopySheet Dim oCurrentController As Object Dim oActiveSheet As Object Dim oSheets As Object oCurrentController = ThisComponent.getCurrentController() oActiveSheet = oCurrentController.getActiveSheet() oSheets = ThisComponent.getSheets() If oSheets.hasByName( oActiveSheet.Name & "Copy" ) Then MsgBox "Sheet name " & oActiveSheet.Name & "Copy, already exists" Else oSheets.copyByName(oActiveSheet.Name, oActiveSheet.Name & "Copy", oActiveSheet.RangeAddress.Sheet + 1) End If End Sub
Bronnen
getCellRangeByPosition()
Kopiëer cellen aan de hand van hun coördinaten - Method van sheets
Syntaxis
data_array = sheet.getCellRangeByPosition ( x_start, y_start, x_end, y_end )
Voorbeeld
function copy_paste_test() ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copy & paste een paar cellen binnen de eerste sheet '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' cell_org=ThisComponent.sheets(0).getCellRangeByPosition(0,0,0,2) cell_dest=ThisComponent.sheets(0).getCellByPosition(3,3) ThisComponent.sheets(0).copyRange _ ( _ cell_dest.CellAddress, _ cell_org.RangeAddress _ ) end function
getDataArray()
Get an array from the contents of the cell range.
Syntaxis
sequence< sequence< any > > getDataArray()
Bronnen
getRowSpan()
The XMergeableCell Interface provides methods to access information about a cell that is mergeable with other sells. getRowSpan returns the number of columns this cell spans.
Inheritance diagram:
XInterface » XCell » XMergeableCell
Syntaxis
long getRowSpan()
Bronnen
- https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1table_1_1XMergeableCell.html
gotoEndOfUsedArea()
Ga met de cursor naar de laatste gebruikte cel in betreffende sheet.
Syntaxis
gotoEndOfUserArea ( boolean bExpand ) bExpand: * true: Expands the current cursor range * false: Sets size of the cursor to a single cell
Voorbeeld
function get_used_area_coordinates() ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Get used area coordinates '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Create a cursor on the first sheet '''''''''''''''''''''''''''''''''''' ' o_cursor = ThisComponent.Sheets(0).createCursor() ' Goto end of used are '''''''''''''''''''''''''''''''''''' ' o_cursor.gotoEndOfUsedArea(false) ' Retrieve number of rows & columns '''''''''''''''''''''''''''''''''''' ' i_rows = o_cursor.getRangeAddress().EndRow+1 i_columns = o_cursor.getRangeAddress().EndColumn+1 ' Display to user '''''''''''''''''''''''''''''''''''' ' msgBox "Rijen: " & i_rows msgBox "Kolommen: " & i_columns end function
hasByName()
true if an element with this name is in the container, false otherwise.
Voorbeeld
function insert_sheet() ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Insert sheet 'Aggregate' (if not exists) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' dim doc as object dim sheet as object doc = ThisComponent if ThisComponent.sheets.hasByName("Aggregate") then ' Do nothing: Sheet "Aggregate" bestaat al ' MsgBox "Sheet 'Aggregate' already exists" else sheet = doc.createInstance("com.sun.star.sheet.Spreadsheet") doc.sheets.insertByName("Aggregate",sheet) end if end function
Opmerkingen
Als je gewoon wilt testen wat de naam van een gegeven sheet is, krijg je een foutmelding. Wat dan bv. wel werkt:
function test_detect_sheet_by_name() ' ' Loop through all sheets ''''''''''''''''''''''''''''''''''''' ' for sheet_counter = 0 to ThisComponent.sheets.count-1 if ThisComponent.sheets(sheet_counter).name="Joepie" then msgbox "Sheet 'Joepie' gevonden bij index " & sheet_counter end if next end function
insertByName
inserts the given element at the specified name.
Syntaxis
void insertByName ( string aName, any aElement )
Lijkt te werken met allerlei soorten objecten. aElement
is waarschijnlijk afhankelijk van het soort object.
Voorbeeld
function insert_sheet_aggregate() ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Insert sheet 'Aggregate' (if not exists) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' dim doc as object dim sheet as object doc = ThisComponent if ThisComponent.sheets.hasByName("Aggregate") then ' Do nothing: Sheet "Aggregate" bestaat al ' ' MsgBox "Sheet 'Aggregate' already exists" else sheet = doc.createInstance("com.sun.star.sheet.Spreadsheet") doc.sheets.insertByName("Aggregate",sheet) end if end function
Bronnen
insertNewByName()
Inserts a new sheet into the collection. You can specify its position!
Voorbeeld
function insert_sheet_aggregate() ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Insert sheet 'Aggregate' at first position (if not exists) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' if ThisComponent.sheets.hasByName("Aggregate") then ' ' Do nothing: Sheet "Aggregate" bestaat al ' else ' ThisComponent.Sheets.insertNewByName("Aggregate", 0) ' end if end function
Bronnen
- https://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheets.html#insertNewByName
isMerged()
returns true if this cell is merged with another cell.
Syntaxis
boolean isMerged()