Difference between revisions of "RU/kb/00000224"
From Wiki
Jump to navigationJump to searchm (1 версия) |
|||
Line 56: | Line 56: | ||
<section begin=signature/> | <section begin=signature/> | ||
− | {{ | + | {{SignYear|Sancho|А. Е. Харламенков|2011}} |
<section end=signature/> | <section end=signature/> | ||
{{RUkbMacrosBottom}} | {{RUkbMacrosBottom}} |
Revision as of 16:26, 27 August 2011
Данный пример кода выполняет поиск от текущей позиции далее «вниз» по листу:
FUNCTION getRowRange(idxSheet, sRow, eRow) as com.sun.star.table.CellRangeAddress
RangeAddr = createUnoStruct( "com.sun.star.table.CellRangeAddress" )
with RangeAddr
.Sheet = idxSheet
.StartColumn = 0
.StartRow = sRow
.EndColumn = 255
.EndRow = eRow
end with
getRowRange() = RangeAddr
END FUNCTION
' копирование строк
' idxSheet - индекс листа
' sRow - нач. строка копируемого диапазона
' eRow - кон. строка копируемого диапазона
' iRow - куда копируется
' How - сколько строк
SUB CopyRows(idxSheet, sRow, eRow, iRow, How)
' vars
Dim Doc, Sheet as object
CellAdr = createUnoStruct( "com.sun.star.table.CellAddress" )
' sub body
Doc = StarDesktop.CurrentComponent
Sheet = Doc.Sheets.getByIndex(idxSheet)
RowRange = getRowRange(idxSheet, sRow, eRow)
for i = 1 to How
with CellAdr
.Sheet = idxSheet
.Column = 0
.Row = iRow + (i-1)
end with
if (iRow >= eRow) and (iRow <= eRow) then
RowRange = getRowRange(idxSheet, sRow + (i-1), eRow + (i-1))
end if
Sheet.CopyRange(CellAdr, RowRange)
next i
END SUB