We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Trying to use SUMPRODUCT function

Thread ID:

Created:

Updated:

Platform:

Replies:

59079 Apr 4,2007 11:42 AM Apr 4,2007 12:18 PM ASP.NET Web Forms (Classic) 1
loading
Tags: Calculate
Ricardo
Asked On April 4, 2007 11:42 AM

Hi,

I'm using the Syncfusion.Calculate.CalcQuick class to make calculations with Excel like functions.
When I try to use the SUMPRODUCT function, it allways return "0".
I'm doing anyhing wrong?
This is my test function:

Public Function TestCalc() As String

Dim calc As Syncfusion.Calculate.CalcQuick
Dim strFormula As String, strResult As String

strFormula = "SUMPRODUCT({1;2;3;4}; {5;6;7;8})"

calc = New CalcQuick
CalcEngine.ParseDecimalSeparator = "."
CalcEngine.ParseArgumentSeparator = ";"

strResult = calc.ParseAndCompute(strFormula)~

Return strResult

End Function


Essential Studio 4.4.0.46
VS 2003
Windows XP

Administrator [Syncfusion]
Replied On April 4, 2007 12:18 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;