dmolony-DiskBrowser/src/com/bytezone/diskbrowser/visicalc/Sum.java

33 lines
586 B
Java
Raw Normal View History

2016-03-06 08:05:32 +00:00
package com.bytezone.diskbrowser.visicalc;
2016-07-31 23:52:47 +00:00
class Sum extends RangeFunction
2016-03-06 08:05:32 +00:00
{
public Sum (Sheet parent, String text)
{
2016-03-09 10:38:53 +00:00
super (parent, text);
2016-03-06 08:05:32 +00:00
}
2016-03-12 05:05:50 +00:00
@Override
2016-03-17 04:40:43 +00:00
public Value calculate ()
2016-03-12 05:05:50 +00:00
{
2016-03-16 06:15:39 +00:00
value = 0;
2016-03-16 19:32:25 +00:00
valueType = ValueType.VALUE;
2016-03-06 08:05:32 +00:00
for (Address address : range)
2016-03-06 23:52:46 +00:00
{
Cell cell = parent.getCell (address);
2016-08-01 05:18:51 +00:00
if (cell == null || cell.isValueType (ValueType.NA))
2016-03-16 06:15:39 +00:00
continue;
2016-08-01 05:18:51 +00:00
if (cell.isValueType (ValueType.ERROR))
2016-03-12 05:05:50 +00:00
{
2016-03-16 19:32:25 +00:00
valueType = ValueType.ERROR;
2016-03-17 04:40:43 +00:00
break;
2016-03-12 05:05:50 +00:00
}
2016-03-17 04:40:43 +00:00
2016-03-16 06:15:39 +00:00
value += cell.getValue ();
2016-03-06 23:52:46 +00:00
}
2016-03-17 04:40:43 +00:00
return this;
2016-03-06 08:05:32 +00:00
}
}