REM ***** BASIC *****
Sub Main
Dim SourceSheet, Sheet
Dim SourceCell, Cell
Dim Col as Integer
Dim Row as Integer
Dim MaxRow as Integer
Dim SourceSheetNr as Integer
Dim TargetSheetNr as Integer
rem !!!!!!!
SourceSheetNr = 0
TargetSheetNr = 1
SourceSheet = ThisComponent.Sheets.getByIndex(SourceSheetNr)
Sheet = ThisComponent.Sheets.getByIndex(TargetSheetNr)
rem !!!!!!!
MaxSourceRow = 1000
rem Cleaning target sheet
Dim CellRangeAddress as New com.sun.star.table.CellRangeAddress
CellRangeAddress.Sheet = TargetSheetNr
CellRangeAddress.StartColumn = 0
CellRangeAddress.EndColumn = MaxSourceRow
CellRangeAddress.StartRow = 0
CellRangeAddress.EndRow = MaxSourceRow
Sheet.removeRange(CellRangeAddress, com.sun.star.sheet.CellDeleteMode.COLUMNS)
rem Number of domains
For SourceRow = 0 to MaxSourceRow
SourceCell = SourceSheet.getCellByPosition(0, SourceRow)
If SourceCell.Type = com.sun.star.table.CellContentType.EMPTY Then
MaxSourceRow = SourceRow - 1
Exit For
End If
Next SourceRow
rem Inserting first row
MaxCol = 0
For SourceRow = 0 to MaxSourceRow
SourceCell = SourceSheet.getCellByPosition(1, SourceRow)
Was = 0
For Col = 0 to MaxCol
Cell = Sheet.getCellByPosition(Col, 0)
If Cell.String = SourceCell.String Then
Was = 1
Exit For
End If
Next Col
If Was = 0 Then
Cell = Sheet.getCellByPosition(MaxCol, 0)
Cell.String = SourceCell.String
MaxCol = MaxCol + 1
End If
Next SourceRow
MaxCol = MaxCol - 1
rem Inserting domains
Dim FirstCell, DomainCell
For Col = 0 to MaxCol
FirstCell = Sheet.getCellByPosition(Col, 0)
Row = 1
For SourceRow = 0 to MaxSourceRow
SourceCell = SourceSheet.getCellByPosition(1, SourceRow)
If FirstCell.String = SourceCell.String Then
Cell = Sheet.getCellByPosition(Col, Row)
DomainCell = SourceSheet.getCellByPosition(0, SourceRow)
Cell.String = DomainCell.String
Row = Row + 1
End If
Next SourceRow
Next Col
End Sub
Rövid magyarázat:
Az 1. táblázat a1:b1000-es tartományát vizsgálja (bedrótozva).
A konvertált értékek a 2. táblázat a1-es mezőjétől kezdődően helyezkednek el.
-----
"Én vagyok a hülye, hogy leállok magával vitatkozni."