Commit 4cedfd4f authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

добавлены функции

SERIESSUM, SUMX2MY2, SUMX2PY2, SUMXMY2

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48434 954022d7-b5bf-4e40-9824-e11837661b57
parent 61b50516
......@@ -36,7 +36,6 @@
<script type="text/javascript" src="../graphics/DrawingContext.js"></script>
<script type="text/javascript" src="../graphics/pdfprinter.js"></script>
<!--TODO: remove test data-->
<!-- <script type="text/javascript" src="../offlinedocs/test-workbook9/Editor.js"></script> -->
<script type="text/javascript" src="../offlinedocs/test-workbook2.js"></script>
......
......@@ -1403,5 +1403,76 @@
} )
test( "Test: \"SUMXMY2\"", function () {
oParser = new parserFormula( "SUMXMY2({2,3,9,1,8,7,5},{6,5,11,7,5,4,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 79 );
oParser = new parserFormula( "SUMXMY2({2,3,9;1,8,7},{6,5,11;7,5,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 78 );
oParser = new parserFormula( "SUMXMY2(7,5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} )
test( "Test: \"SUMX2MY2\"", function () {
oParser = new parserFormula( "SUMX2MY2({2,3,9,1,8,7,5},{6,5,11,7,5,4,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), -55 );
oParser = new parserFormula( "SUMX2MY2({2,3,9;1,8,7},{6,5,11;7,5,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), -64 );
oParser = new parserFormula( "SUMX2MY2(7,5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} )
test( "Test: \"SUMX2MY2\"", function () {
oParser = new parserFormula( "SUMX2PY2({2,3,9,1,8,7,5},{6,5,11,7,5,4,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 521 );
oParser = new parserFormula( "SUMX2PY2({2,3,9;1,8,7},{6,5,11;7,5,4})", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 480 );
oParser = new parserFormula( "SUMX2PY2(7,5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} )
test( "Test: \"SERIESSUM\"", function () {
ws.getRange2( "A2" ).setValue( "=1" );
ws.getRange2( "A3" ).setValue( "=-1/Fact(2)" );
ws.getRange2( "A4" ).setValue( "=1/Fact(4)" );
ws.getRange2( "A5" ).setValue( "=-1/Fact(6)" );
oParser = new parserFormula( "SERIESSUM(PI()/4,0,2,A2:A5)", "A7", ws );
ok( oParser.parse() );
ok( Math.abs( oParser.calculate().getValue() - (1 - 1 / 2 * Math.pow( Math.PI / 4, 2 ) + 1 / Math.fact( 4 ) * Math.pow( Math.PI / 4, 4 ) - 1 / Math.fact( 6 ) * Math.pow( Math.PI / 4, 6 )) ) < dif );
ws.getRange2( "B2" ).setValue( "=1" );
ws.getRange2( "B3" ).setValue( "=-1/Fact(3)" );
ws.getRange2( "B4" ).setValue( "=1/Fact(5)" );
ws.getRange2( "B5" ).setValue( "=-1/Fact(7)" );
oParser = new parserFormula( "SERIESSUM(PI()/4,1,2,B2:B5)", "B7", ws );
ok( oParser.parse() );
ok( Math.abs( oParser.calculate().getValue() - (Math.PI / 4 - 1 / Math.fact( 3 ) * Math.pow( Math.PI / 4, 3 ) + 1 / Math.fact( 5 ) * Math.pow( Math.PI / 4, 5 ) - 1 / Math.fact( 7 ) * Math.pow( Math.PI / 4, 7 )) ) < dif );
// strictEqual( oParser.calculate().getValue(), Math.PI / 4 - 1 / Math.fact( 3 ) * Math.pow( Math.PI / 4, 3 ) + 1 / Math.fact( 5 ) * Math.pow( Math.PI / 4, 5 ) - 1 / Math.fact( 7 ) * Math.pow( Math.PI / 4, 7 ) );
} )
} );
This diff is collapsed.
......@@ -2189,6 +2189,42 @@ cArea3D.prototype.countCells = function () {
}
return new cNumber( count );
};
cArea3D.prototype.getMatrix = function () {
var arr = [],
r = this.getRange();
for ( var k = 0; k < r.length; k++ ) {
arr[k] = [];
r[k]._foreach2( function ( cell, i, j, r1, c1 ) {
if ( !arr[k][i - r1] )
arr[k][i - r1] = [];
if ( cell ) {
switch ( cell.getType() ) {
case CellValueType.Number:
arr[k][i - r1][j - c1] = cell.getValueWithoutFormat() == "" ? new cEmpty() : new cNumber( cell.getValueWithoutFormat() )
break;
case CellValueType.Bool:
arr[k][i - r1][j - c1] = new cBool( cell.getValueWithoutFormat() );
break;
case CellValueType.Error:
arr[k][i - r1][j - c1] = new cError( cell.getValueWithoutFormat() );
break;
case CellValueType.String:
arr[k][i - r1][j - c1] = new cString( cell.getValueWithoutFormat() );
break;
default:
if ( cell.getValueWithoutFormat() && cell.getValueWithoutFormat() != "" ) {
arr[k][i - r1][j - c1] = new cNumber( cell.getValueWithoutFormat() )
}
else
arr[k][i - r1][j - c1] = checkTypeCell( "" + cell.getValueWithoutFormat() );
}
}
else
arr[k][i - r1][j - c1] = new cEmpty();
} )
}
return arr;
}
/** @constructor */
function cRef3D( val, _wsFrom, wb ) {/*Ref means Sheat1!A1 for example*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment