AD
Administrator
Syncfusion Team
April 4, 2007 04:18 PM UTC
You will not be able to use 'vectors' with the SumProduct formula through a CalcQuick object. But you can use a CalcWorkbook and a CalcSheet to manage this kind of calculation. These allow you to use Excel like range references which the SumProduct formula can then handle. Here is a little Windows Forms code that shows how you might go about this.
Imports Syncfusion.Calculate
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFormula As String, strResult As String
' strFormula = "SUMPRODUCT({1;2;3;4}; {5;6;7;8})"
'put first vector in row 1
sheet(1, 1) = 1 '(row,col)
sheet(1, 2) = 2
sheet(1, 3) = 3
sheet(1, 4) = 4
'put second vector in row 2
sheet(2, 1) = 5 '(row,col)
sheet(2, 2) = 6
sheet(2, 3) = 7
sheet(2, 4) = 8
strFormula = "SUMPRODUCT(A1:D4,B1:B4)"
'strFormula = "SUMPRODUCT(A1:D4;B1:B4)"
strResult = sheet.Engine.ParseAndComputeFormula(strFormula)
Me.Label1.Text = strResult
End Sub
Dim sheet As CalcSheet
Dim workBook As CalcWorkbook
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sheet = New CalcSheet(10, 10)
workBook = New CalcWorkbook(New CalcSheet() {sheet}, Nothing)
''if you want semicolon listseparator, uncomment this code and use the second definition of strFormula above
'CalcEngine.ParseDecimalSeparator = "."
'CalcEngine.ParseArgumentSeparator = ";"
End Sub
End Class