POI Excel公式计算引擎服务

POI Excel公式计算引擎服务 计算引擎服务 Excel公式计算引擎服务 idea Excel公式计算引擎服务 package com.exampl

POI Excel公式计算引擎服务

计算引擎服务

Excel公式计算引擎服务

idea在这里插入图片描述

Excel公式计算引擎服务
package com.example.demo.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**

  • @author :

  • @date :Created in 2020/11/5 10:37

  • @description:

  • @modified By:

  • @version: $
    /
    @Controller
    public class TestController {
    @ResponseBody
    @RequestMapping(value = “/test”, method = RequestMethod.POST, produces = “application/json;charset=UTF-8”)
    public String writeByBody(@RequestBody JSONObject jsonParam) {
    // 直接将json信息打印出来
    System.out.println(jsonParam.toJSONString());
    //获取运算符
    String name3 = jsonParam.getString(“name3”);
    //获取第一个参数
    String name2 = jsonParam.getString(“name2”);
    //获取第二个参数
    String name1 = jsonParam.getString(“name1”);
    int result = 0;
    //判断操作符
    if (name3.equals("+")){//加法运算
    result = Integer.parseInt(name2) + Integer.parseInt(name1);
    } else if (name3.equals("-")){//减法运算
    result = Integer.parseInt(name1) - Integer.parseInt(name2);
    } else if (name3.equals("
    ")){//乘法运算
    result = Integer.parseInt(name2) * Integer.parseInt(name1);
    } else if (name3.equals("/")){//除法运算
    result = Integer.parseInt(name1) / Integer.parseInt(name2);
    }

     // 把每个参数和操作符,以及运算封装成json格式,然后返回给前端JSONObject json = new JSONObject();json.put("msg", "ok");json.put("symbol", name3);json.put("name2", name2);json.put("name1", name1);json.put("result", result);return json.toJSONString();
    

    }

}