SPREAD for Windows Forms 10.0J サンプルコード集
テーブルを追加・削除する

テーブルを追加するには、SheetViewクラスのAddTableメソッドを使用し、テーブルを削除するには、SheetViewクラスのRemoveTableメソッドを使用します。

【実行例】

private void Form1_Load(object sender, EventArgs e)
{
    // テストデータの設定
    fpSpread1.ActiveSheet.Cells[0, 0].Value = "名前";
    fpSpread1.ActiveSheet.Cells[0, 1].Value = "性別";
    fpSpread1.ActiveSheet.Cells[0, 2].Value = "報酬";
    fpSpread1.ActiveSheet.Cells[0, 3].Value = "職業";
    fpSpread1.ActiveSheet.Cells[1, 0].Value = "佐藤";
    fpSpread1.ActiveSheet.Cells[1, 1].Value = "男";
    fpSpread1.ActiveSheet.Cells[1, 2].Value = 300000;
    fpSpread1.ActiveSheet.Cells[1, 3].Value = "教師";
    fpSpread1.ActiveSheet.Cells[2, 0].Value = "高橋";
    fpSpread1.ActiveSheet.Cells[2, 1].Value = "男";
    fpSpread1.ActiveSheet.Cells[2, 2].Value = 300000;
    fpSpread1.ActiveSheet.Cells[2, 3].Value = "エンジニア";
    fpSpread1.ActiveSheet.Cells[3, 0].Value = "木村";
    fpSpread1.ActiveSheet.Cells[3, 1].Value = "女";
    fpSpread1.ActiveSheet.Cells[3, 2].Value = 320000;
    fpSpread1.ActiveSheet.Cells[3, 3].Value = "教師";
    fpSpread1.ActiveSheet.Cells[4, 0].Value = "高山";
    fpSpread1.ActiveSheet.Cells[4, 1].Value = "女";
    fpSpread1.ActiveSheet.Cells[4, 2].Value = 270000;
    fpSpread1.ActiveSheet.Cells[4, 3].Value = "会計士";
    // テーブルの追加
    fpSpread1.ActiveSheet.AddTable("table1", 0, 0, 5, 4);
}
private void button1_Click(object sender, EventArgs e)
{
    // テーブルの削除
    fpSpread1.ActiveSheet.RemoveTable("table1");
}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' テストデータの設定
    FpSpread1.ActiveSheet.Cells(0, 0).Value = "名前"
    FpSpread1.ActiveSheet.Cells(0, 1).Value = "性別"
    FpSpread1.ActiveSheet.Cells(0, 2).Value = "報酬"
    FpSpread1.ActiveSheet.Cells(0, 3).Value = "職業"
    FpSpread1.ActiveSheet.Cells(1, 0).Value = "佐藤"
    FpSpread1.ActiveSheet.Cells(1, 1).Value = "男"
    FpSpread1.ActiveSheet.Cells(1, 2).Value = 300000
    FpSpread1.ActiveSheet.Cells(1, 3).Value = "教師"
    FpSpread1.ActiveSheet.Cells(2, 0).Value = "高橋"
    FpSpread1.ActiveSheet.Cells(2, 1).Value = "男"
    FpSpread1.ActiveSheet.Cells(2, 2).Value = 300000
    FpSpread1.ActiveSheet.Cells(2, 3).Value = "エンジニア"
    FpSpread1.ActiveSheet.Cells(3, 0).Value = "木村"
    FpSpread1.ActiveSheet.Cells(3, 1).Value = "女"
    FpSpread1.ActiveSheet.Cells(3, 2).Value = 320000
    FpSpread1.ActiveSheet.Cells(3, 3).Value = "教師"
    FpSpread1.ActiveSheet.Cells(4, 0).Value = "高山"
    FpSpread1.ActiveSheet.Cells(4, 1).Value = "女"
    FpSpread1.ActiveSheet.Cells(4, 2).Value = 270000
    FpSpread1.ActiveSheet.Cells(4, 3).Value = "会計士"
    ' テーブルの追加
    FpSpread1.ActiveSheet.AddTable("table1", 0, 0, 5, 4)
End Sub
 
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    ' テーブルの削除
    FpSpread1.ActiveSheet.RemoveTable("table1")
End Sub

 

 


© 2004-2017, GrapeCity inc. All rights reserved.