本帖最后由 Joestar.Xu 于 2023-7-28 10:34 编辑
如图, 定义一个转换中文金额大写的lambda公式运行报错, 这个lambda公式在spreadjs下能正常使用
代码如下:
- Workbook workbook = new Workbook();
- workbook.getNames().add("ADD1", "=LAMBDA(x, X+1)");
- workbook.getActiveSheet().getRange("A1").setFormula("=ADD1(123)");
- System.out.println(workbook.getActiveSheet().getRange("A1").getValue());
- workbook.getNames().add("CNAMOUNT", "=LAMBDA(amount, ""&IF(TRIM(amount)="","",IF(amount=0,"",""&IF(amount<0,"负","")&IF(INT(amount),TEXT(INT(ABS(amount)),"[dbnum2]")&"圆",)&IF(INT(ABS(amount)*10)-INT(ABS(amount))*10,TEXT(INT(ABS(amount)*10)-INT(ABS(amount))*10,"[dbnum2]")&"角",IF(INT(ABS(amount))=ABS(amount),,IF(ABS(amount)<0.1,,"零")))&IF(ROUND(ABS(amount)*100-INT(ABS(amount)*10)*10,),TEXT(ROUND(ABS(amount)*100-INT(ABS(amount)*10)*10,),"[dbnum2]")&"分","整"))))");
- workbook.getActiveSheet().getRange("A2").setFormula("=CNAMOUNT(123)");
- System.out.println(workbook.getActiveSheet().getRange("A2").getValue());
复制代码
|
|