如何使用java在excel中读取和写入值?
- Sample Excel --> Sorry I'm not allowed to attached a image..
- TC No. | Title | Result
- 1 | State and Vin | Failed
- 2 | State and Reg Code | Passed
- 3 | Booking a Test Drive | Passed
public class sampleTest{
public static void main(String[] args) throws Exception {
int iTest = 2, iTest2 = 3;
if (iTest == iTest2){
//It will pass a value into the excel (e.g. "Passed")
}
else{
//It will pass a value into the excel (e.g. "Failed")
}
}
我的程序的目标是通过从测试中获得通过和失败的结果来生成报告。我这里的主要问题是如何从excel中读取结果,并将值“通过”或“失败”放在结果列下
# 1 楼答案
从here下载apache poi jar 通过这些examples演示如何从java程序读取/写入xls数据 示例帮助代码:
这可能会帮助您开始。 整个流程是:
可以有多种类型的单元格,有关详细信息,请参见this。 要了解如何读取excel文件,请执行以下操作:
有关更多信息,请参见this
# 2 楼答案
通过将作为Excel文档界面的库。一个选项是Apache POI。Excel示例代码可以在here中找到
另一个选择是Java Excel API