aoiu / as3xls

Automatically exported from code.google.com/p/as3xls
0 stars 0 forks source link

Wrong value for INT() function, adding new functions to the formulas, issue with sum of elements #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Read excel file with formulas with 'INT()' 
2.  ROUNDDOWN(sth,sth), ROUNDUP(sth,sth) functions
3. Issue with SUM of many cells

Please provide any additional information below.

First I would like to thank for this library, great work , it saved me a 
lot of time :). 

I have found however some few small bugs and I also found the solution for 
them. 
1. In excels that I had to load the formulas with INT function did not 
work properly. That is because the Excel INT function always returns 
Intiger value of the input rounded down.
In .as file the Math.round(rest[0]) function is used which gives faulty 
results.  To correct it just change the line 161 in 
com/as3xls/formula/formula.as file to 'return Math.floor(rest[0]);'     

2. In my input excels in formulas I had ROUNDDOWN & ROUNDUP funcions which 
were not supported by as3xls. I did some research in excel file 
specification (e.g. http://sc.openoffice.org/excelfileformat.pdf ) and 
found the function codes and inputs ('212' and '213'). 
To add the functions those following files have to be modified: 
com/as3xls/xls/formula/Functions.as   :
  - additional elements in the tables 'names' and 'args' (file in attach)
com/as3xls/xls/formula/Formula.as
  - two additional case alements in 'builtInFunction' function:

e.g.:
    case 212:   // ROUNDUP
    return Math.ceil(rest[0]);
    case 213:   // ROUNDDOWN
    return Math.floor(rest[0]);

I needed only rounding to INT value so I don't use second argument from 
Excel input.  

I guess this issue can be helpful if you have to add any other missing 
formulas.

3. I got a wrong result value with following example formula:
   "=(D7/(D4+D5+D6+D7+D8))"   ,  
quick fix to "=(D7/SUM(D4:D8))" gave the right value.  
I don't know what caused the error, if someone have time them mybe can 
investigate it. :)

BR
Rafal

Original issue reported on code.google.com by rafal.sz...@gmail.com on 17 May 2010 at 12:18

Attachments: