GcSpreadSheetでは、ワークシートにて配列数式を使用することができます。配列数式は、名前が示すように、配列での1つ以上の項目に対して計算を行う数式のことです。単一または複数の結果を返すことができます。
IRangeインタフェースのFormulaArrayプロパティを使用することで、ワークシートで配列数式を作成できます。
//シートにデータを追加します。 GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells[0, 0].Text = "単位"; GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells[0, 1].Text = "価格"; GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells[0, 2].Text = "合計"; GcSpreadSheet.Workbook.ActiveSheet.Cells[0, 0].Value = 2; GcSpreadSheet.Workbook.ActiveSheet.Cells[1, 0].Value = 5; GcSpreadSheet.Workbook.ActiveSheet.Cells[2, 0].Value = 1; GcSpreadSheet.Workbook.ActiveSheet.Cells[3, 0].Value = 9; GcSpreadSheet.Workbook.ActiveSheet.Cells[0, 1].Value = 40; GcSpreadSheet.Workbook.ActiveSheet.Cells[1, 1].Value = 100; GcSpreadSheet.Workbook.ActiveSheet.Cells[2, 1].Value = 25; GcSpreadSheet.Workbook.ActiveSheet.Cells[3, 1].Value = 80; //配列数式 GcSpreadSheet.Workbook.ActiveSheet.Range("C1:C4").FormulaArray = "A1:A4*B1:B4";
'シートにデータを追加します。 GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells(0, 0).Text = "単位" GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells(0, 1).Text = "価格" GcSpreadSheet.Workbook.ActiveSheet.ColumnHeader.Cells(0, 2).Text = "合計" GcSpreadSheet.Workbook.ActiveSheet.Cells(0, 0).Value = 2 GcSpreadSheet.Workbook.ActiveSheet.Cells(1, 0).Value = 5 GcSpreadSheet.Workbook.ActiveSheet.Cells(2, 0).Value = 1 GcSpreadSheet.Workbook.ActiveSheet.Cells(3, 0).Value = 9 GcSpreadSheet.Workbook.ActiveSheet.Cells(0, 1).Value = 40 GcSpreadSheet.Workbook.ActiveSheet.Cells(1, 1).Value = 100 GcSpreadSheet.Workbook.ActiveSheet.Cells(2, 1).Value = 25 GcSpreadSheet.Workbook.ActiveSheet.Cells(3, 1).Value = 80 '配列数式 GcSpreadSheet.Workbook.ActiveSheet.Range("C1:C4").FormulaArray = "A1:A4*B1:B4"