MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集
チャートを追加する(チャートシートの使用)

IChartsインターフェースのAddメソッドを使用してチャートシートを追加できます。チャートシートはシート上にデータやチャートが表示されるのとは異なりチャートがシートを占有します。

  • 新しいスタイルシステム(LegacyBehaviorsプロパティがStyleを含まない場合)で有効です。
  • 拡張シェイプエンジン(EnhancedShapeEngineプロパティ)を有効にする必要があります。

【実行例】

private void Form1_Load(object sender, EventArgs e)
 {
  fpSpread1.TabStripRatio = 0.8f;

  // 拡張シェイプエンジンを有効にします
  fpSpread1.Features.EnhancedShapeEngine = true;

  // データを設定します
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 1].Value = "S1";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 2].Value = "S2";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 3].Value = "S3";

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 0].Value = "1Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 0].Value = "2Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 0].Value = "3Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 0].Value = "4Q";

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 1].Value = 50;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 1].Value = 30;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 1].Value = 20;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 1].Value = 40;

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 2].Value = 30;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 2].Value = 15;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 2].Value = 50;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 2].Value = 20;

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 3].Value = 10;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 3].Value = 40;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 3].Value = 25;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 3].Value = 25;

  // チャートシートの追加と参照の設定を行います
  fpSpread1.AsWorkbook().Charts.Add();
  fpSpread1.ActiveSheet.Charts[0].DataFormula = "Sheet1!A1:D5";
 }
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  FpSpread1.TabStripRatio = 0.8F

  ' 拡張シェイプエンジンを有効にします
  FpSpread1.Features.EnhancedShapeEngine = True

  ' データを設定します
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 1).Value = "S1"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 2).Value = "S2"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 3).Value = "S3"

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 0).Value = "1Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 0).Value = "2Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 0).Value = "3Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 0).Value = "4Q"

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 1).Value = 50
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 1).Value = 30
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 1).Value = 20
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 1).Value = 40

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 2).Value = 30
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 2).Value = 15
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 2).Value = 50
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 2).Value = 20

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 3).Value = 10
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 3).Value = 40
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 3).Value = 25
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 3).Value = 25

  ' チャートシートの追加と参照の設定を行います
  FpSpread1.AsWorkbook().Charts.Add()
  FpSpread1.ActiveSheet.Charts(0).DataFormula = "Sheet1!A1:D5"
 End Sub

 

 


© MESCIUS inc. All rights reserved.