开发者

Are there any libraries for Apache POI Spreadsheets to handle r/w ing of formulas w/ more precision than double?

Initially i was after a BigDecimal with more functionality than the simple +-*/ which is significantly less than whats available on java.lang.Math.

Please no comments about sin and similar functions that produce or require irrational numbers not being a big fit. The simple answer to that question is to use MathContext with an appropriate/sensible precision limit. I had originally only selected BigDecimal simply because it offers more digits of precision that double.

One idea i had was to make use of the Apache Poi library hoping that it contained a working Function interface with real implementations for all (well maybe not all but lots of ) the functions that are found within a spreadsheet. Unfortunately browsing the javadoc i couldnt find anything similarly named interface/classes.

  • Are there any other libraries that can help with doing maths on poi excel cells using something w/ more precision than double ?
  • the best i can tell is to make 开发者_如何学Cuse of apache commons math ?
  • it appears that the number related functions in org.apache.poi.hssf.record.formula.functions.* only work w/ doubles.


The excel format stores all numbers internally as a double. So, while you could potentially calculate answers to a higher precision, if you stored them back into an excel file you'd loose that. Additionally, if you got excel to calculate the value itself, then the answer it'd save would be limited to double precision.

If you wanted to do formula evaluation with POI, it's mostly setup around evaluating the contents of a cell. One option is to create a cell, set your formula into it then evaluate. See the Apache POI eval documentation for details.

The org.apache.poi.ss.formula.functions package contains all the excel formula function implementations that POI supports, but they may be a bit low level for you (they work on Ptgs, Ops etc)


Yes, Andy Khan's JExcel can handle formulas.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜