SheetViewクラスのAddSpanCellメソッド呼び出しを行います。また、CellクラスのColumnSpanプロパティまたは RowSpanプロパティの設定によっても同等の結果が得られます。
|
private void Form1_Load(object sender, System.EventArgs e) { //セル(1,1)を基点に3列を結合します fpSpread1.ActiveSheet.AddSpanCell(1, 1, 1, 3); //セル(3,3)を基点に2行×2列を結合します fpSpread1.ActiveSheet.Cells[3, 3].RowSpan = 2; fpSpread1.ActiveSheet.Cells[3, 3].ColumnSpan = 2; //各アンカーセルに対する設定 fpSpread1.ActiveSheet.Cells[1, 1].BackColor = Color.LightCyan; fpSpread1.ActiveSheet.Cells[3, 3].BackColor = Color.LightPink; fpSpread1.ActiveSheet.Cells[1, 1].Text = "列の結合"; fpSpread1.ActiveSheet.Cells[3, 3].Text = "行列の結合"; fpSpread1.ActiveSheet.Cells[3, 3].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; fpSpread1.ActiveSheet.Cells[3, 3].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 'セル(1,1)を基点に3列を結合します FpSpread1.ActiveSheet.AddSpanCell(1, 1, 1, 3) 'セル(3,3)を基点に2行×2列を結合します FpSpread1.ActiveSheet.Cells(3, 3).RowSpan = 2 FpSpread1.ActiveSheet.Cells(3, 3).ColumnSpan = 2 '各アンカーセルに対する設定 FpSpread1.ActiveSheet.Cells(1, 1).BackColor = Color.LightCyan FpSpread1.ActiveSheet.Cells(3, 3).BackColor = Color.LightPink FpSpread1.ActiveSheet.Cells(1, 1).Text = "列の結合" FpSpread1.ActiveSheet.Cells(3, 3).Text = "行列の結合" FpSpread1.ActiveSheet.Cells(3, 3).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center FpSpread1.ActiveSheet.Cells(3, 3).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center End Sub