Thiscomponent sheets


ThisComponent.Sheets é a forma de acessar as planilhas de um documento Calc. ThisComponent.Sheets é um array de objetos, e pode ser acessado como um array normal (através dos índices; lembrando que no BASIC os arrays se iniciam no zero) sub subSetDate oDoc = thisComponent oSelection = oDoc. getCurrentSelection nFormat = fnGetNumberFormatId (oDoc, "DD/MM/YY") if HasUnoInterfaces (oSelection, "com.sun.star.lang.XServiceInfo") then if oSelection. supportsService ("com.sun.star.sheet.SheetCellRanges") then 'More than one range selected subSetRanges (oSelection, vValue, nFormat ... Dim Doc As Object Dim Sheet As Object Dim Cell As Object Doc = ThisComponent Sheet = Doc. Sheets (0) Cell = Sheet. getCellByPosition (1, 1) Cell. Value = 1000 Select Case Cell. Type Case com. sun . star . table . Dim Doc As Object Dim Sheet As Object Dim CellRange As Object Doc = ThisComponent Sheet = Doc. Sheets. getByName ("Sheet 1") CellRange = Sheet. getCellRangeByPosition (0, 0, 2, 14) The arguments of getCellRangeByPosition are the position of the upper left cell of the range, followed by the position of the bottom right cell of the same range. Dim Doc As Object Dim Sheet As Object Doc = ThisComponent Sheet = Doc. Sheets (0) ThisComponent returns the currently active document. The expression Doc.Sheets(0) is a Basic simplification of the API call : Doc.getSheets.getByIndex(0)