如何使用Java填充预先设计的电子表格?

时间:2015-07-01 19:10:22

标签: java

我可能会以错误的方式解决这个问题,但这是目标:

我想在电子表格中填充特定字段(颜色键控),其中包含用户输入的数字和这些输入所做的解决方案。电子表格不必是交互式的。基本上,(无法找到解决方案)我试图将变量传递到电子表格中的特定单元格。我可以使用Access或Excel实现这一点,但这只是较大应用程序的一小部分。如果有帮助,最终用户输入和计算需要存储在数据库中并按日期组织/键入;每天都会输入新的输入和计算。这是我的测试程序:

/* 
    Test program to generate spreadsheet and populate specific cells 
    with the scanner inputs from the user and the solution derived
    from scanner inputs
*/

import java.util.Scanner;

class TestRecord {
    String name;
    double a;
    double b;


    double calc_average() {
        double x = (a+b) / 2;
        System.out.println("The average is " + x);
        return x;
    }
}

class SheetGenerator {

    public static void main(String[] args) {

    TestRecord dingdong = new TestRecord();

        double calculatedAverage;

        Scanner in = new Scanner(System.in);

        dingdong.name = "Dipity";

        System.out.println("Enter the value the numbers for " +      dingdong.name);
        System.out.println();
        System.out.println("Enter the value for a: ");
        dingdong.a = in.nextDouble();
        System.out.println("Enter the value for b: ");
        dingdong.b = in.nextDouble();

        calculatedAverage = dingdong.calc_average();

    }
}

1 个答案:

答案 0 :(得分:1)

我在Apache POI库方面取得了很大成功。非常容易使用和理解。

特定于Excel和电子表格,请使用HSSF & XSSF

相关问题