MESCIUS SPREAD for Windows Forms 15.0J サンプルコード集
テーブルの自動展開

テーブルの下にある行または右にある列の空のセルに入力を行うと、新しい行または列がテーブルとして追加されます。このようにテーブルの行または列を自動的に展開するにはAutoExpandTableプロパティを使用します。

新しいスタイルシステム(LegacyBehaviorsプロパティがStyleを含まない場合)で有効です。

【実行例】入力前

【実行例】入力後

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);

  // テーブルの自動展開を有効
  fpSpread1.Features.AutoExpandTable = true;
 }
Private Sub Form1_Load(sender As Object, e As 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)

  ' テーブルの自動展開を有効
  FpSpread1.Features.AutoExpandTable = True

 End Sub

 

 


© MESCIUS inc. All rights reserved.