gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:21:32 25 4
gpt4 key购买 nike

我的方法可能是错误的,但目标是:

我想使用用户输入的数字和这些输入得出的解决方案来填充电子表格中的特定字段(颜色键控)。电子表格不必是交互式的。本质上,(无法找到解决方案)我试图将变量传递到电子表格中的特定单元格中。我可以使用 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();

}
}

最佳答案

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

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

关于java - 如何使用 Java 填充预先设计的电子表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31169713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com