From 1ab42424ac6aa35af78787ba989819791b60c855 Mon Sep 17 00:00:00 2001 From: Rosie <3392418386@qq.com> Date: Fri, 5 Mar 2021 16:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AF=E5=88=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/function/CellSum.class | Bin 0 -> 1118 bytes src/main/java/com/fr/function/CellSum.java | 14 ++ src/main/java/com/fr/function/DateDiff.class | Bin 0 -> 2990 bytes src/main/java/com/fr/function/DateDiff.java | 67 ++++++++ .../java/com/fr/function/FlagHtmlColor.class | Bin 0 -> 2365 bytes .../java/com/fr/function/FlagHtmlColor.java | 67 ++++++++ src/main/java/com/fr/function/IRR.class | Bin 0 -> 4440 bytes src/main/java/com/fr/function/IRR.java | 152 ++++++++++++++++++ .../java/com/fr/function/ReportCheck.class | Bin 0 -> 4591 bytes .../java/com/fr/function/ReportCheck.java | 127 +++++++++++++++ src/main/java/com/fr/function/StringCat.class | Bin 0 -> 840 bytes src/main/java/com/fr/function/StringCat.java | 15 ++ .../java/com/fr/function/StringImage.class | Bin 0 -> 2436 bytes .../java/com/fr/function/StringImage.java | 59 +++++++ src/main/java/com/fr/function/Ubm.class | Bin 0 -> 1336 bytes src/main/java/com/fr/function/Ubm.java | 25 +++ 16 files changed, 526 insertions(+) create mode 100644 src/main/java/com/fr/function/CellSum.class create mode 100644 src/main/java/com/fr/function/CellSum.java create mode 100644 src/main/java/com/fr/function/DateDiff.class create mode 100644 src/main/java/com/fr/function/DateDiff.java create mode 100644 src/main/java/com/fr/function/FlagHtmlColor.class create mode 100644 src/main/java/com/fr/function/FlagHtmlColor.java create mode 100644 src/main/java/com/fr/function/IRR.class create mode 100644 src/main/java/com/fr/function/IRR.java create mode 100644 src/main/java/com/fr/function/ReportCheck.class create mode 100644 src/main/java/com/fr/function/ReportCheck.java create mode 100644 src/main/java/com/fr/function/StringCat.class create mode 100644 src/main/java/com/fr/function/StringCat.java create mode 100644 src/main/java/com/fr/function/StringImage.class create mode 100644 src/main/java/com/fr/function/StringImage.java create mode 100644 src/main/java/com/fr/function/Ubm.class create mode 100644 src/main/java/com/fr/function/Ubm.java 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 0000000000000000000000000000000000000000..7f13b3cde76fa1ef7a0f5b4e16239a31f37b101a GIT binary patch literal 1118 zcmZ`(OHgR2cEa$8l z3~hPSHkQ0{(QucwqD7Hp-qAH{RdY?@hrt+sVOAJ=^SV=3*IjkpvvqDdwwg06tKgNh z1nYV>!$|shenWeysg`D!)W^jQL+9Di(;*r_b4vu7I-{PzDqdNPQim#V*R)H-6L*b@ zXK@C(;CQZXESO?yB^+c@bSOw7MbIaQEvzgm=tZA|TMDUrN5YhXyO?I^K1uY*Gp#kl zW#~G5yH)-CwfgQu_08+UF9*MN_l^!eD!7OH3bL4y@Ib*V=0xNn>3MYU>2Pbm`hGho zB3kv7mZ2joC~6f$UE!uhdbK(=O_!bEqY1?uR0;)u z)~I+;NXoU>HyPA1B)Ag@%g~u_Y^uwxZEhO&8pA{*PnbU45$Z;4EhU5JG)wm^jXNad z0O23sa6L=qJ^#zmcN9pT>l!xCIhI$ppE$1=`Wx`LII8NuB*7h<_Kaf~Y~b&-7^1t= zL01lR#pv82MQbN{Dp^LhDYFCiy_W8xHC_wGah~3lpa9+IA&>3|`e+r++XNOPJH3y{ z(;Y;|e8i%=Xz~$X+=oP=M6%h3obhqahvK6p*-Gv>JwDo&CcaT`1cEPF!%3hG%`}>f lDPk4enE*fJCMNV_fY?*?lemCE>Yk$KBE3Z^dZ~st^amdk9?t*( literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b9219065f73974b7f2aec93126e0041d6c55daa8 GIT binary patch literal 2990 zcmaJ@TXYju6y3K;I+Hj>2r0D)Dk_quKzLc9sMr>&#g-z43R;0_I%x;;VlqJxP!v#n zzaQWeUnqzcl~6%lez{!!_^WHlzsnE5{ZZU^9&NDI)y~a1=bn2W`j;)36Gk(#5#*4UR6)Ux2tu%=q^Q7FQ3_F8x%>27M5wS+#r;wse%iYcDt1X4M<4uw z^lpc~UOPzo0f!FV&_{ZYL!;@B{VMjlG=ATzVxLC`ev{4~RPaz3`|+@XM)`Mc~ZqwDxQwe!!s(Ljo>*vui^!%{-TPP6uc}&ugLvZ zBMOcROfDLhsb_i(t7ztP8#-1Bh}8l$ZTVc$)^m2Ro+%ljpIaMe4FC07n?Q9sZ)J5` zAlkW2->D}vdTub;V_Rl!aJfKWz)aI-#a3tD*{HtR%$fGB)QC6q3IyBo1BSrmoo3Eh zQ_A)m)_T1^LrJtVpJFsRV`Xv#bmRx&&hE$Eh>ZLutU zcX!%#CNOn^2#9Bot*5qk=>;bx2mBrdud~boie(fsdWzZ4j#tFsfm$JPuyo)n+7^Qm z+xc`5O|lHRp>9+sq^_W6;=@^tPC-tJ@G`xdj8s5b*w$Z;Ej8MhnE6j%74H`D#9-rOOz&N^m?tXHv+Q29^BsH?WyvXD4 z;eD2B%)w~E6?~xKLmU^V8{2g;Z7rFZ0mIVp5k3}B`}Xt=Bv$n8({KVO34w-Ba7x3c z_>5p^7{+N0pW~!JRo@-~X!rtON@kyeGaAY`OJ?>0X>Ekj4P271+e{LtuOw*aG@O@* zulTP45V*?QDyA&6U?*Gp*%NxoZudsT2ih4|w<+BG#y5eVdBx6XJ19Hlb{Fv`5%gG%WAz)Fml9m-b79+#_5u(@}O$x{o#qlE0c4j)KKWP;B@!@ z*sj2BY^)UCneId_u8gW}NVj^79VH`|GW>h0;{4dG1=FTXiKw#eLxWbnRN%aM7e`Ab zBe1m6t{3sRWPKl(-r7^fI=v%j^FrX@tGqsn23cN=6IgEO5SS6~7>|-SBm`^PrQ4om zZY-O?-UOHCc-uUyc`3J>R?)^RzJr(Zl^eix+>Bcwa4WegtRTg!#-Vx3I2uCUK$PE3 zZY57}BoR%Vg-D1qs7i!K5IBS2Y3IxxTqjWn2qVbJ4WkAfgh%oQ?FJn zV@dQz_eAg;G;IphhDLBx&j^+_hij{kU}m7HI>At61ht_nt| Gu>BwS0@zdl literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c65900c96e81beb9c89d042f63eaf317095845e9 GIT binary patch literal 2365 zcmbVOOHfl+82(OjUkO3rN{}F;eOQ74;{#Cxs1T)qBq~@`u<9k;gwT*+a^tj}E<4?I z+Zns5wmP`zLS4j}I>V}~uDkEDGhKFR9qo5+0*X+l<4o><{``<9o6kBY1iay{X#pi(n70KQCbD@uSzem6ix;iA z93|#NA!X&JtzuTb*My3*kSz)9o=6pzqUmBZUCyVRY#|>V$yu3EXDJsick@b)e28O-_Ikp;a9HRTku`3&=@DVdP| zX%@idigu}-qjCL|W2HVzSj%qVIxY+NGqxj3q_4nucyqM>BYC~}^&-3_8B(P9#Q9|T zj0yNkj#YFPm{CBt^Yc~CQ<@WK-IQv$oKD;B;Bt1}T~&e=PZi3=ls%Gl_pxEb`{gVG z*o6)O=(rNV3}$s)4d7E;ljFDNSw%8{C=Lkhcyn^YipGJoJI6RFP}h>@ADsPy?_q7eEU00oX`O_lzV9lE^X42<&<*R0KL|`ckTxU3Q{F za~!6Xaz<*%5@>ugJ^NYnaU?dQ=Zo2;tdqS()cVg%PM({*o*YV?5eTipl$+RKN8r2` zwTept!zol(D$pF>a?zT#yv$7s^lSm2%^tNWGn>Y(W}F50qa!pL?VDvQR~pOY3q?C_ zl~{OitB4$*mRhiiLqxO^9_u2y+Qad;CFWGjHpr;O zm>N`wOtldW5l!JvQJ78Zm$-Ud$%OX>|cXTt*9S z(0UOex6u>TW@?SHEqsJdw(6xt7+oBVh79(R^D;{c5poK3UUZXF(Zgy?s4vj0V}JGM zZD|WK0zcg9$asZ&SRKUtQy5pCz-Rg^sO#oq21qKXk16K1nEDhA)HcSnNCi!Ox~cV4 zVBW@zx6cR~LH$Q0B0-~q?R~zWukpZL9N=;MCv?@K%3;+7eHAo^)LK}7NDDDn@X`wE zLYmaIT>9D&D=#0f;CFLJHU7eS{MpyyTX*4S{4ejJiN{bi+swOVySIY0*;>suyPhri zDqB+$ZUQs(ZV4W(K#e>MX%)1+LdrMpe%sOJBEN%M-OX+7K_BI(xbIOydz!$$Nz8n~ zt$#&}uc`Z%+y0JwzQYYapvSM+k3YE0Ke^Apa1eh}_YZo7f+J!Z`a}zk@}oE=PT{y1 zMNFJUznG%#Do%=P{AVCPr=N+!n?&nDV#d$R12}}kMDB57vX?kDm|;!(fLN_+Z}Sp% zwTxZUGTUHPD|AfOe2J_z{F0NX6%uVOYCSF|QR_vU7-#nqza3%(N6D$^6oWX%IyCf% zqlmE<-Np0-%$F4Vbo8$SdyN?ojQ"; + 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 0000000000000000000000000000000000000000..86a951ce3b999aebfebd6dbd1004420f3b130f63 GIT binary patch literal 4440 zcmd5MurlS+5|8lYzJAU7MMVq(6KzW$I;@BMu17u zETubvkTz|TZj>%=x+Df#*$FMp*Y<1s2im7ke?UK_JW1U5%*e7aQlI2o1>8CJ+2;Cb5b66O{XnE2iu5DzzS!jDf3#ofklByD`>hLq?|y5|Gv57wcD(y= zO+j5=Hw`U4sGE5smp##YSb_4Gg5`&D*}SD?twAka&^^Y#|M}PVHzlqrSQZ-?=pQ&U z*cCq!Q&1lt*UoCuw3Z!>CN0y*j&>^WccoGVQ%g-MXmr*ynl%KY`tH_MChks(L(HeN}mvW zw54k1C|#|tV2g+(EiLtQpEhB~MOrEFSf-ZcfpBP%!F!$GkF5KwmS)(xlkmdzl+N*b zY^z73Tl$ZXjZcdCeiKrgh5xetRPz5lnva{Xb4_P%a4tubLSLvS2nw{%wef>JxrI1|TMv0ievppTPX{HHpRdd!L3IZi#MHaxtO$nQ<1OJ!c0 z%oWU(e#8)t`&p+uF@CS03OC80TeM4z+RDN@lF8yMS55E?Gx#?NRNti3x5!!e^ju(6ly+Y z8WUEuYe@KzvW}E`8r%Is#>q)uNQPICE3jTmJrp?O~|G+ zZ?&OPZ{n4%TXGHEPJ=mN8EF!7Mb2)a$8*k0L&4TcW)^ilXCLFa$6rY+P2Zc=v!m7+ z(+RcqvSG0QW%R7oC8>paE4FGkiKSp?MbGm%TJold+D-A8nLBF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ecimal(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; j9)H&>+EdW zDrgl@tJSKYf&wZY)p}9TZORH3u|@C%K@n6GZ}C3GU+lf-*8NHxA!LxUQRY6z?GeHt3o_T!y$Y`jUNr;cHE)iWB9nlof3CxXu;hL*nm$+d{V=7 z1wI|0Qri?{y80NnN8-~OK7-F{Xv61%6qtXl>(%PGI{&=H7c?wXBAifb(rCdK)#png zd|91*C4{eraW76v+^1oMf|!c?6@jlQgp*->9R-O~8rEVsjMI2PqNrg#z9I3ThE6;r z@lA;{0>R$w_WpeWdQT=}IbA6;m$PyLbqBVZS%HaL_L)Pbk$00RW0RTN%gxmS^=p!u zq`OWa&^~u3VY}=BOJMAlWX9T-Pxo6+ui2mC&V(&?!c6Tnoupd(n|1EqBpI}9N!V#) zk7Mk~XA*AG&KNtatnIj6d#%KN@(4KjjKG}sT_p)pW@gZ!pjN_NJ@>*bflwmv_*a>A zG19X=ATkh1{`Uxs*=Gw}QbyUAqa>SS+qe0=sF6ZGGmnYd9_?V<@OP*lVD^XDjx}4T7!~IXH!NMpr*LzIvmG5Brv56T9MK_ zQ1o0Yo$d1sIbk&I)H|MX1uD8JZ5aMg60l?ek_#uSRBB_&N?RFMV0xLY53CN2t`P{O zOj^6Sit)yS2`j6t%CkDt8Kl7{j$%mxnaH{ss#iIS=W3pzW3H3T3=+2?VW%>lOL6Yl z2g>uXW4U=Jv(rrFiCUkw2lC3{CYL2GZ5Ug#Z|zz!%NeqqDwuX3#y6}lU+Gp#f-2DEKInkynuh147syN}qTRe;u0m|7 z-}*h+FQS-ku5rOO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YoWL$oz_sELTqmA}NeOq0XK}rF9{ry8p20-&S%DaOp^JHx?rQ8r6ZzbT zKD>c@t#A>?HT;?3nCQkXTuZOMoqVsu8~Ibjaj^)yaXrK5tQZHARKw)E5(x|t_XOs{ z!X7k|XApzfOI*f-A1i8>#6Idyis!H&DMr_L@dVP8Ab_dj95S5Mp_S6xq#Q(6IMm>q z7=MRFKOAC6J@4_G#WC{De<;?iha0}6J}9N^%wRX_O4!oA5#?v;Y Hnr`6#)?ynO literal 0 HcmV?d00001 diff --git a/src/main/java/com/fr/function/ReportCheck.java b/src/main/java/com/fr/function/ReportCheck.java new file mode 100644 index 0000000..21d57da --- /dev/null +++ b/src/main/java/com/fr/function/ReportCheck.java @@ -0,0 +1,127 @@ +// 自定义函数实现表间校验 +package com.fr.function; + +import java.util.HashMap; +import com.fr.base.ResultFormula; +import com.fr.base.operator.common.CommonOperator; +import com.fr.chart.activator.ChartBaseActivator; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.data.impl.config.activator.RestrictionActivator; +import com.fr.env.operator.CommonOperatorImpl; +import com.fr.io.TemplateWorkBookIO; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.main.impl.WorkBook; +import com.fr.main.workbook.ResultWorkBook; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; +import com.fr.report.cell.CellElement; +import com.fr.report.module.ReportBaseActivator; +import com.fr.report.report.ResultReport; +import com.fr.script.AbstractFunction; +import com.fr.stable.WriteActor; +import com.fr.store.StateServerActivator; +import com.fr.workspace.simple.SimpleWork; +import com.fr.write.cal.WB; + +public class ReportCheck extends AbstractFunction { + private static HashMap wMap = new HashMap(); + + public Object run(Object[] args) { + // 获取公式中的参数 + String cptname = args[0].toString(); // 获取报表名称 + int colnumber = Integer.parseInt(args[2].toString()); // 所取单元格所在列 + int rownumber = Integer.parseInt(args[3].toString()); // 所取单元格所在行 + // 定义返回的值 + Object returnValue = null; + // 定义报表运行环境,用于执行报表 + Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), + new ConfigurationActivator(), + new StateServerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator(), + new ChartBaseActivator()); + SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); + String envpath= "//Applications//FineReport10_325//webapps//webroot//WEB-INF"; //工程路径 + SimpleWork.checkIn(envpath); + module.start(); + try { + ResultWorkBook rworkbook = null; + // 读取模板 + WorkBook workbook = (WorkBook)TemplateWorkBookIO + .readTemplateWorkBook(cptname); + // 获取需要传递给报表的参数名与参数值,格式如[{"name":para1name,"value":para1value},{"name":para2name,"value":para2value},......] + JSONArray parasArray = new JSONArray(args[1].toString()); + // 需要判断是否是5秒内执行过的 + // 取出保存的resultworkbook; + Object tempWObj = wMap.get(cptname + parasArray.toString()); + if (tempWObj != null) { + // 取出hashmap里面保存的TpObj; + TpObj curTpObj = (TpObj) tempWObj; + + if ((System.currentTimeMillis() - curTpObj.getExeTime()) < 8000) { + rworkbook = curTpObj.getRworkbook(); + } else { + wMap.remove(cptname + parasArray.toString()); + } + } + // 如果没有设置,需要生成 + if (rworkbook == null) { + JSONObject jo = new JSONObject(); + // 定义报表执行时使用的paraMap,保存参数名与值 + java.util.Map parameterMap = new java.util.HashMap(); + if (parasArray.length() > 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 0000000000000000000000000000000000000000..56028335fe94d418ca852e67fb04684a894ece08 GIT binary patch literal 840 zcmZ`%-EI;=6#iy+VPU(pl@@EQwpLM~K({fCHy9Ib(!>PX3rrK^)v#=F>UNh5vp#`O z;*If6Z)l=PAHY}eNxZ3^=@O-)B%C?F-}%0i{dV!?9KbG`4)WN@;f{?>2PQVOx$EE_ z%GxX2xNqYDL-w(VgnGhYR%=HL)?VBX7#7+h3J#LfULaraUPzf@JN9{a#HG;jBx$MF zV#Ki4_Ty9USbE1vMBIai0Bl$iu-Rme0ZtBMuoxY#)X(?_tpO7 zYz&Kk?;tgNI1HjbL$f+{k%^q?170CTLZ`6Ob2H>roOUrRS7&Ei*hG##8~rm#F)1hO zQsmJ~M?hxl4D9n|xj;6XCNWRGJMkB=ND;#|6v^u0j|7&Xcc*A{%tuzqs-M3{xn8m! z9(;xQ@(fmEj7)QkEInh`op%=d@bi1)6U~^=dv4Muz@{iqu|vpnbo4y7Dbl-l3BQP2 xSi&;(WT{rdby!r{LCQyaE4V?7Of<1dhz8cEUVw3dtWC4*2P#y)O-TdmzW|MBx;g*= literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..f620b5093acf72552d5ae23f76f922d65dc7c175 GIT binary patch literal 2436 zcmaJ?U2_vv7=BK(o2AP_3nkD%3n?GcPZmo-X%V3fE!DI|3Kc|=O|nfF((Jm~Q0m7W z7ybptEA^t|IL_crs5&xw<&3|# zNGrIaU|PY9iWsh{n8kZ4l6YT1M#T=yDVSHWfNKgqP@y5c1K0icqKY=$@K-ne$I?!G zh+8Ud<0BP!@NxXodHUc_#V5F{;8O+n1mYL0lI2|#i1iOF2}o0R-W2G_SS545vYIvB z8%DNB$=-~eGm1-wYx&=iQ1Vu+vOsSpXRqqZuD)C;5HCgl?t<~M!}pQv|A|& zob11oxoh`K&(KphFwUa0?8#t3@0vglm>7MNgnJ^k}SkdMyFr2(;N*fnAH9 zk$W&_I6(n|8V<1=LANq2n_tU@+y%z^8xjn6CSJymYS8FVDjBOm(YFg084JjkUsi!V zWv6JAS0*dV%Vs`^RN(M7cA%vPyKc14610a#Go$%>X??#luHmd$x$(gdWPbBd+x(6|v)gThn9};%YFERglw=hpFKl z-eTVZ=w>EpSoXc{4z}tQR8Y{c0@CQfb~qvMWW_4xO;=#w%~HAIIJWDV`INWrm??WX zrQtpvXeeUUUzIf2a1?x|!9`htr=fy}3f43{!n%UbHGF|D1rEK2{_IJ#Th6(bW=l@RXO3yCGU)z@5`M1R8*EL&Pv?;y^w!_>nJ~LRX48-zJsYv@ zCA$WKwPru?q#$oo3v&yG|N0Uvuq; z7HiG8X;yg6YfTkwVa0eYtk>>uftyLwMAAyhxO@J+i$}51L9g4_+Ccsci z#NO8?!&i$OMA>GIvKfwnTA*s)HP&ji8f=KMHY}n+7PKR(UOGLn zgg)L?2ZNg?1|AOd@Y&06oo~UnJopUaXD-@sn9q11?7|VQwNL>mf`IFzIL0T9#ZQo+ zQ1+vki(Qm|N87j*J0~aPq37S>Sg-Uw4i6>d(Z3Mi!0x2f>whdhj)}*z*x33fDM_P$ zBK8C${^}3J#^u4J6yr)t%2mjlh(Ciew*hrLo{U$~zJYXTqdq~ht{T{?q2}>T?EDSd z?Pu7vcXt&XzIqj%RqUx^?=R?T!|+pvKEs>$F7NDEkm@|Tn8JQ0et_w8^CnIPwMwx{ z$C&02wN6no#>6jDGJ_Me?A6QSnWY>wli+jhZD^p9R?nxGP zhFJa7m;Ite1@%{h^upVW_QM$ATfzo?o?wJ3z9r@mC8ud~0qt7^jw^Um!Ki{Wf-kl& zp}v5;Md0Qgg+Wu}>aPpK4g;vh|cGYozVJ8>4Bgi8?c2;L5oz8Y|$ubx&P<>%>+PB0#%C6jg&Od>}6 c{dkAvl!&qi@8S|s6J*+Dt`yo#241KB1I|xWI{*Lx literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..32253acf204a81e1854e5ca574be8a66f8e9cbb7 GIT binary patch literal 1336 zcmZ`&T~iWa6nxQ63%VzIiSla5XAoLBt}1d)_b&dx62Jgf|$3L}^E7=t~)< zo~iEVbZbq`70KdDl{B@up;`vln?}LjH7X2&lvdi0<*iu0YHGGoGGptx{Wz7hswTsz zvYpyf57byuH4CxT+@7x4@o>9|!J+Lkumnw^S_P`>?~q7UE4IbwY1PcymSGmCp`&6G zqFgnf*C}MEEo8awp}?N3t!i)6YPk+X#6#kgLCTh@mZq;59I%HlM0pPx0St;*lCcb$ z4Ge?-wr1G|MR4v85c*K}A-Y)H8Tn4I0G!WoqzG@a)nb?|^dtHqOX&7j?5> z(~Zz(B#E4gty*?v)8M9n(#CB({F 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