diff --git a/src/main/java/com/fr/function/CellSum.class b/src/main/java/com/fr/function/CellSum.class
new file mode 100644
index 0000000..7f13b3c
Binary files /dev/null and b/src/main/java/com/fr/function/CellSum.class differ
diff --git a/src/main/java/com/fr/function/CellSum.java b/src/main/java/com/fr/function/CellSum.java
new file mode 100644
index 0000000..e0b860d
--- /dev/null
+++ b/src/main/java/com/fr/function/CellSum.java
@@ -0,0 +1,14 @@
+package com.fr.function;
+
+import com.fr.base.Utils;
+import com.fr.script.AbstractFunction;
+
+public class CellSum extends AbstractFunction {
+ public Object run(Object[] args) {
+ String sum = Utils.objectToNumber(new SUM().run(args), false)
+ .toString(); // 直接调用FR内部的SUM方法
+ String result = "所在单元格为:" + this.getCalculator().getCurrentColumnRow()
+ + ";总和为:" + sum; // 获取当前单元格拼出最终结果
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/DateDiff.class b/src/main/java/com/fr/function/DateDiff.class
new file mode 100644
index 0000000..b921906
Binary files /dev/null and b/src/main/java/com/fr/function/DateDiff.class differ
diff --git a/src/main/java/com/fr/function/DateDiff.java b/src/main/java/com/fr/function/DateDiff.java
new file mode 100644
index 0000000..3066667
--- /dev/null
+++ b/src/main/java/com/fr/function/DateDiff.java
@@ -0,0 +1,67 @@
+package com.fr.function;
+
+import com.fr.script.AbstractFunction;
+import com.fr.stable.Primitive;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DateDiff extends AbstractFunction
+{
+ private static final long serialVersionUID = -2863679010825725885L;
+ public String format = null;
+ private Long dif = Long.valueOf(0L);
+
+ public Object run(Object[] paramArrayOfObject)
+ {
+ try
+ {
+ Long localLong1 = Long.valueOf(((Date)paramArrayOfObject[0]).getTime());
+ Long localLong2 = Long.valueOf(((Date)paramArrayOfObject[1]).getTime());
+ this.dif = Long.valueOf(localLong2.longValue() - localLong1.longValue());
+ this.format = ((String)paramArrayOfObject[2]);
+ replace("((?i)y)", Long.valueOf(31536000000L));
+ replace("((?i)q)", Long.valueOf(7776000000L));
+ replace("M", Long.valueOf(2592000000L));
+ replace("((?i)w)", Long.valueOf(604800000L));
+ replace("((?i)d)", Long.valueOf(86400000L));
+ replace("((?i)h)", Long.valueOf(3600000L));
+ replace("m", Long.valueOf(60000L));
+ replace("((?i)s)", Long.valueOf(1000L));
+ try
+ {
+ return Long.valueOf(Long.parseLong(this.format));
+ }
+ catch (Exception localException2)
+ {
+ return this.format;
+ }
+ }
+ catch (Exception localException1)
+ {
+ }
+ return Primitive.ERROR_VALUE;
+ }
+
+ public void replace(String paramString, Long paramLong)
+ {
+ Pattern localPattern = Pattern.compile(paramString + "\\{\\d*?\\}");
+ Matcher localMatcher = localPattern.matcher(this.format);
+ int i = (int)(this.dif.longValue() / paramLong.longValue());
+ int j = 1;
+ while (localMatcher.find())
+ {
+ String str1 = localMatcher.group();
+ str1 = str1.replaceAll(paramString + "\\{", "");
+ str1 = str1.replaceAll("\\}", "");
+ int k = Integer.parseInt(str1);
+ String str2 = String.format("%0" + k + "d", new Object[] { Integer.valueOf(i) });
+ if (j != 0)
+ {
+ j = 0;
+ this.dif = Long.valueOf(this.dif.longValue() - i * paramLong.longValue());
+ }
+ this.format = this.format.replaceFirst(paramString + "\\{\\d*?\\}", str2);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/FlagHtmlColor.class b/src/main/java/com/fr/function/FlagHtmlColor.class
new file mode 100644
index 0000000..c65900c
Binary files /dev/null and b/src/main/java/com/fr/function/FlagHtmlColor.class differ
diff --git a/src/main/java/com/fr/function/FlagHtmlColor.java b/src/main/java/com/fr/function/FlagHtmlColor.java
new file mode 100644
index 0000000..76da40b
--- /dev/null
+++ b/src/main/java/com/fr/function/FlagHtmlColor.java
@@ -0,0 +1,67 @@
+package com.fr.function;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.Primitive;
+public class FlagHtmlColor extends AbstractFunction {
+ public Object run(Object[] args) {
+ String txt="";
+ String color="";
+ String flag="";
+ if(null==args||args.length==0){
+ return Primitive.ERROR_NAME;
+ }else if(args.length==1){
+ txt=args[0].toString();
+ color="red";
+ flag="N";
+ }else if(args.length==2){
+ txt=args[0].toString();
+ color=args[1].toString();
+ flag="N";
+ }else{
+ txt=args[0].toString();
+ color=args[1].toString();
+ flag=args[2].toString();
+ }
+ String result=getHtmlStr(txt, color, flag);
+ return result;
+ }
+ public String getHtmlStr(String txt,String color,String flag){
+ String starthtml="";
+ String endhtml="";
+ StringBuffer sb=new StringBuffer();
+ int len=txt.length();
+ if("N".equalsIgnoreCase(flag)){//数字
+ for(int i=0;i='0'&&c<='9'){
+ String str=starthtml+c+endhtml;
+ sb.append(str);
+ }else{
+ sb.append(c);
+ }
+ }
+ }else if("C".equalsIgnoreCase(flag)){//字母
+ for(int i=0;i='a'&&c<='z')||(c>='A'&&c<='Z')){
+ String str=starthtml+c+endhtml;
+ sb.append(str);
+ }else{
+ sb.append(c);
+ }
+ }
+ } else if("Z".equalsIgnoreCase(flag)){//中文
+ for(int i=0;i= 0x4E00 && c <= 0x9FA5){
+ String str=starthtml+c+endhtml;
+ sb.append(str);
+ }else{
+ sb.append(c);
+ }
+ }
+ }else{
+ return txt;
+ }
+ return sb.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/IRR.class b/src/main/java/com/fr/function/IRR.class
new file mode 100644
index 0000000..86a951c
Binary files /dev/null and b/src/main/java/com/fr/function/IRR.class differ
diff --git a/src/main/java/com/fr/function/IRR.java b/src/main/java/com/fr/function/IRR.java
new file mode 100644
index 0000000..46bdb96
--- /dev/null
+++ b/src/main/java/com/fr/function/IRR.java
@@ -0,0 +1,152 @@
+package com.fr.function;
+
+import java.math.BigDecimal;
+
+import com.fr.general.FArray;
+import com.fr.general.GeneralUtils;
+import com.fr.script.AbstractFunction;
+
+public class IRR extends AbstractFunction {
+
+ private static final long serialVersionUID = 7634415917398642321L;
+ private static final String ERROR_VALUE = "#NUM!";
+
+
+ @Override
+ public Object run(Object[] args) {
+ try{
+ if(1 == args.length){
+ return run( transArr( (FArray) args[0] ) );
+ }else if(2 == args.length){
+ return run( transArr( (FArray) args[0] ), trans( args[1] ) );
+ }
+ }catch(Exception e){
+ System.out.println(e);
+ }
+ return ERROR_VALUE;
+ }
+
+ /**
+ * 将其他类型的数字转换为大数(保证精度)
+ * @param ele
+ * @return
+ */
+ private static BigDecimal trans(Object ele){
+ try{
+ String val = GeneralUtils.objectToString(ele);
+ return new BigDecimal(val);
+ }catch(Exception e){
+
+ }
+ return (BigDecimal) ele;
+ }
+
+ /**
+ * 将数组转换为大数数组
+ * @param in
+ * @return
+ */
+ private static FArray transArr(FArray in){
+ FArray rt = new FArray();
+ for(int i=0;i cashflow){
+ return run( cashflow, new BigDecimal(0.1d) );
+ }
+
+ private static BigDecimal run(FArray cashflow,BigDecimal guess){
+ BigDecimal maxrate = initRateMax(cashflow,guess);
+ BigDecimal minrate = initRateMin(cashflow,guess);
+ for( int i=0; i cashflow,BigDecimal guess){
+ for( int i=0; i cashflow,BigDecimal guess){
+ for( int i=0; i cashflow,BigDecimal rate){
+ BigDecimal npv = ZERO;
+ BigDecimal rpowj = ONE;//(1+r)^0
+ BigDecimal radd1 = rate.add(ONE);//1+r
+ for( int j=0; j 0) {
+ for (int i = 0; i < parasArray.length(); i++) {
+ jo = parasArray.getJSONObject(i);
+ parameterMap.put(jo.get("name"), jo.get("value"));
+ }
+ }
+ // 执行报表
+ rworkbook = workbook.execute(parameterMap, new WriteActor());
+ // 保存下来
+ wMap.put(cptname + parasArray.toString(), new TpObj(rworkbook,
+ System.currentTimeMillis()));
+ }
+ // 获取报表结果中对应Cell的值
+ ResultReport report = rworkbook.getResultReport(0);
+ CellElement cellElement = ((WB) report).getCellElement(colnumber, rownumber);
+ returnValue = cellElement.getValue().toString();
+ if(cellElement.getValue() instanceof ResultFormula) {
+ returnValue = ((ResultFormula)cellElement.getValue()).getResult().toString();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return returnValue;
+ }
+
+ class TpObj {
+ private ResultWorkBook rworkbook = null;
+ private long exeTime = System.currentTimeMillis();
+
+ public TpObj(ResultWorkBook rworkbook, long exeTime) {
+ this.setRworkbook(rworkbook);
+ this.setExeTime(exeTime);
+ }
+
+ public ResultWorkBook getRworkbook() {
+ return rworkbook;
+ }
+
+ public void setRworkbook(ResultWorkBook rworkbook) {
+ this.rworkbook = rworkbook;
+ }
+
+ public long getExeTime() {
+ return exeTime;
+ }
+
+ public void setExeTime(long exeTime) {
+ this.exeTime = exeTime;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/StringCat.class b/src/main/java/com/fr/function/StringCat.class
new file mode 100644
index 0000000..5602833
Binary files /dev/null and b/src/main/java/com/fr/function/StringCat.class differ
diff --git a/src/main/java/com/fr/function/StringCat.java b/src/main/java/com/fr/function/StringCat.java
new file mode 100644
index 0000000..00cbf16
--- /dev/null
+++ b/src/main/java/com/fr/function/StringCat.java
@@ -0,0 +1,15 @@
+package com.fr.function;
+
+import com.fr.script.AbstractFunction;
+
+public class StringCat extends AbstractFunction {
+ public Object run(Object[] args) {
+ String result = "";
+ Object para;
+ for (int i = 0; i < args.length; i++) {
+ para = args[i];
+ result += para.toString();
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/StringImage.class b/src/main/java/com/fr/function/StringImage.class
new file mode 100644
index 0000000..f620b50
Binary files /dev/null and b/src/main/java/com/fr/function/StringImage.class differ
diff --git a/src/main/java/com/fr/function/StringImage.java b/src/main/java/com/fr/function/StringImage.java
new file mode 100644
index 0000000..1345f16
--- /dev/null
+++ b/src/main/java/com/fr/function/StringImage.java
@@ -0,0 +1,59 @@
+//图片在下文字在上
+package com.fr.function;
+
+import com.fr.base.GraphHelper;
+import com.fr.data.core.db.BinaryObject;
+import com.fr.log.FineLoggerFactory;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.CoreGraphHelper;
+import javax.imageio.ImageIO;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+
+
+/**
+ * 图片在下文字在上
+ */
+public class StringImage extends AbstractFunction {
+ @Override
+ public Object run(Object[] args) {
+ Image result = null;
+ int p = 0;
+ Object[] ob = new Object[2];
+ for (int i = 0; (i < args.length && p <= 1); i++) {
+ if (args[i] == null) {
+ continue;
+ }
+ ob[p] = args[i];
+ p++;
+
+ }
+
+ if (ob[1] instanceof BinaryObject) {
+ BinaryObject binaryObject = (BinaryObject) ob[1];
+ try {
+ result = initStringImage((String) ob[0], ImageIO.read(binaryObject.getInputStream()));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else if (ob[1] instanceof Image) {
+ result = initStringImage((String) ob[0], (Image) ob[1]);
+ } else {
+ FineLoggerFactory.getLogger().warn("Unsupported type of " + ob[1].getClass());
+ }
+
+ return result;
+ }
+
+ private Image initStringImage(String name, Image image) {
+ BufferedImage splashBuffedImage = CoreGraphHelper.toBufferedImage(image);
+ Graphics2D splashG2d = splashBuffedImage.createGraphics();
+ double centerX = 25;
+ double centerY = 25;
+ GraphHelper.drawString(splashG2d, name, centerX, centerY);
+ return splashBuffedImage;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/function/Ubm.class b/src/main/java/com/fr/function/Ubm.class
new file mode 100644
index 0000000..32253ac
Binary files /dev/null and b/src/main/java/com/fr/function/Ubm.class differ
diff --git a/src/main/java/com/fr/function/Ubm.java b/src/main/java/com/fr/function/Ubm.java
new file mode 100644
index 0000000..12d7aaf
--- /dev/null
+++ b/src/main/java/com/fr/function/Ubm.java
@@ -0,0 +1,25 @@
+// 自定义函数Unicode编码转化为中文
+package com.fr.function;
+
+import com.fr.script.AbstractFunction;
+
+public class Ubm extends AbstractFunction {
+ public Object run(Object[] args) {
+ String str = args[0].toString();
+ String st = "";
+ StringBuffer buffer = new StringBuffer();
+ while (str.length() > 0) {
+ if (str.startsWith("%u")) {
+ st = str.substring(2, 6);
+ char ch = (char) Integer.parseInt(String.valueOf(st), 16);
+ buffer.append(new Character(ch).toString());
+ str = str.substring(6);
+ } else {
+ st = str.substring(0, str.indexOf("%u"));
+ buffer.append(st);
+ str = str.substring(st.length());
+ }
+ }
+ return buffer.toString();
+ }
+}
\ No newline at end of file