ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2015-06-05 18:01:47

ebrouen
Member
Registered: 2015-05-20
Posts: 6

Behaviour of SUM function

Hi Jing,

I found a difference between Excel behaviour and Reogrid in the SUM function (maybe in other ones).
If you use SUM(A1,A2,A3) and A2 is empty (cell has no instance), the result is empty.
If, in the same conditions, you use SUM(A1:A3), the result is correct.
When you have to add non adjacent cells, this can be a handicap.

Eric

Edit: Sorry, I just found same request of January the 18th, 2015... Anything new since the 0.8.8.5 version or I missed something?

Last edited by ebrouen (2015-06-05 18:10:29)

Offline

#2 2015-06-06 14:02:19

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Behaviour of SUM function

OK, let me check and fix this problem. Thanks for the information.

Jing

Offline

#3 2015-06-07 02:01:46

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Behaviour of SUM function

Hi Eric, there is a bug in built-in SUM function, instead please use the following one 'SUM_2' before the next version available.

Run this code once before using 'SUM_2' function:

unvell.ReoGrid.Formula.FormulaExtension.CustomFunctions["SUM_2"] = (cell, args) =>
  {
	double val = 0;

	foreach (var arg in args)
	{
		if (arg is ReoGridRange)
		{
			cell.Worksheet.IterateCells((ReoGridRange)arg, (r, c, inCell) =>
			{
				val += inCell.Worksheet.GetCellData<double>(r, c);
				return true;
			});
		}
		else if (arg is ReoGridCell)
		{
			val += cell.Worksheet.GetCellData<double>((ReoGridPos)arg);
		}
		else if (arg is double)
		{
			val += (double)arg;
		}
      }

      return val;
  };

And the usage: (same as 'SUM' function)

var sheet = reoGridControl1.CurrentWorksheet;

sheet["B2"] = new object[] { 1, null, 3, 4 };

sheet["C4"] = new object[] { "'=SUM_2(B2:E2)", null, "=SUM_2(B2:E2)" };
sheet["C6"] = new object[] { "'=SUM_2(B2, C2, D2, E2)", null, "=SUM_2(B2, C2, D2, E2)" };

Test result:
s04.png

ebrouen wrote:

Edit: Sorry, I just found same request of January the 18th, 2015... Anything new since the 0.8.8.5 version or I missed something?

No I think you didn't smile I missed something, could you provide the URL of previous request? I'd like to reply it.

Regards, Jing

Last edited by Jingwood (2015-06-07 02:05:36)

Offline

#4 2015-06-07 10:32:10

ebrouen
Member
Registered: 2015-05-20
Posts: 6

Re: Behaviour of SUM function

Hi Jing,

Thank's for the answer.
The previous request was here : https://reogrid.net/forum/viewtopic.php?id=72.
I used a workaround by testing in my code if the cell has instance, and if the cell's data is not null. For the moment, I can continue with it. But of course, I'm not the only user of this super control smile

Sorry to ask for it, but when do you plan to release the next version? (with user-defined format, I would love it! https://reogrid.net/forum/viewtopic.php?id=124)

Regards,
Eric

Offline

#5 2015-06-07 14:03:33

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Behaviour of SUM function

Thanks for the link. I'm working on preparing for the next release, I think it would be available within next week.

Offline

#6 2015-09-07 03:06:12

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Behaviour of SUM function

SUM function has been improvement in 0.8.9.2 version.

Offline

Board footer

Powered by FluxBB