Java根据公式自动计算关联单元格的值

Java根据公式自动计算关联单元格的值,第1张

将下面的代码保存为index2jsp即可

<%@ page language="java" import="javautil" pageEncoding="UTF-8"%>

<%

String path = requestgetContextPath();

String basePath = requestgetScheme() + "://"

+ requestgetServerName() + ":" + requestgetServerPort()

+ path + "/";

String strRow = requestgetParameter("row");

String strCol = requestgetParameter("col");

String formula = requestgetParameter("formula");

strRow = strRow == null "7" : strRow;

strCol = strCol == null "5" : strCol;

int row = IntegerparseInt(strRow, 10);

int col = IntegerparseInt(strCol, 10);

formula = formula == null "" : formula;

char[] chr = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',

'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',

'W', 'X', 'Y', 'Z' };

class Item {

private int type;

private String item;

public static final int OPERATOR = 0;

public static final int ARG = 1;

public static final int CONST = 2;

public Item(){}

public Item(String item, int type){

thisitem = item;

thistype = type;

}

public Item(char item, int type){

thisitem = ""+item;

thistype = type;

}

public int getType() {

return type;

}

public void setType(int t) {

type = t;

}

public String getItem() {

return item;

}

public void setItem(String s) {

item = s;

}

public void setItem(char s) {

item = ""+s;

}

}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

<title>二维表公式自动计算</title>

<meta >

在java程序添加spirexlsjar依赖

import comspirexls;

public class ReadExcel {

    public static void main(String[] args) {

        //创建Workbook对象

        Workbook wb = new Workbook();

        //加载一个Excel文档

        wbloadFromFile("C:\\Users\\Administrator\\Desktop\\testxlsx");

        //获取第一个工作表

        Worksheet sheet = wbgetWorksheets()get(0);

        //遍历工作表的每一行

        for (int i = 1; i < sheetgetLastRow() + 1; i++) {

            //遍历工作的每一列

            for (int j = 1; j < sheetgetLastColumn() + 1; j++) {

                //输出指定单元格的数据

                Systemoutprint(sheetget(i,j)getText());

                Systemoutprint("\t");

            }

            Systemoutprint("\n");

        }

    }

}

以上就是关于Java根据公式自动计算关联单元格的值全部的内容,包括:Java根据公式自动计算关联单元格的值、浅谈JAVA读写Excel的几种途径、java如何读取整个excel文件的内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/9448206.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存