(OpenOffice Basic)Calcで行と列の表示・非表示と選択セルの種類
OpenOffice 3.2.0です。
基本的に列ならセルオブジェクトの Columns.IsVisible 、行ならセルオブジェクトの Rows.IsVisible に True ,False をセットすることで設定できるようです。
oSheet.getCellByPosition( 0 , 0 ).Columns.IsVisible = True
oSheet.getCellByPosition( 0 , 0 ).Rows.IsVisible = True
下記に現在選択しているセルもしくはセル範囲の列を非表示にするというコードをあげてみました。
Dim blFlg As BooleanblFlg = False
Dim oSheet As Object
oSheet = ThisComponent.CurrentController.ActiveSheet
Dim oActiveCell As Object
oActiveCell = ThisComponent.CurrentSelection
If oActiveCell.ImplementationName = "ScCellObj" Then '1セルの場合
'列非表示
oSheet.getCellByPosition( oActiveCell.CellAddress.Column , 0 ).Columns.IsVisible = blFlg
ElseIf oActiveCell.ImplementationName = "ScCellRangeObj" Then 'セルRangeひとつの場合
For iCol = oActiveCell.RangeAddress.StartColumn To oActiveCell.RangeAddress.EndColumn
'列表示
oSheet.getCellByPosition( iCol , 0 ).Columns.IsVisible = blFlg
Next iCol
ElseIf oActiveCell.ImplementationName = "ScCellRangesObj" Then 'セルRangeが複数の場合
For i = 0 To UBound(oActiveCell.RangeAddresses)
For iCol = oActiveCell.RangeAddresses(i).StartColumn To oActiveCell.RangeAddresses(i).EndColumn
oSheet.getCellByPosition( iCol , 0 ).Columns.IsVisible = blFlg
Next iCol
Next i
Else 'セル選択されていない時
End If
選択しているセルが一つだけの場合、セルRange(セル範囲)、セルRage複数の場合で切り分けないといけないようですね。
カレントセルの ImplementationName が ScCellObj ならセル一つ選択、ScCellRangeObj ならセルRange、ScCellRangesObj ならセルRangeが複数という意味だそうです。
参考: