0

如何使用 Java bean 提取 xls 文件中的数据。因为,我不熟悉beans,所以有人可以解释一下如何从下面的代码中获取xls文件中的结果并进行系统调用以打开xls文件。

私有静态字符串 getDGrid(){ 字符串 jsonObj=null;

    OppDownListBean dropDownBean = new OppDownListBean();

    List dataDDL=opptyMgmtDAO.getOppViewData();

    StringBuffer sb = new StringBuffer("{\"items\":[");
    int slno=0;
    if (dataDDL != null) {
        for (int i = 0; i<dataDDL.size(); i++) {
            slno=i+1;
            odb=(OppDataBean)dataDDL.get(i);
            sb.append("{\"slno.\":" + "\"" + slno + "\"," +"\"customer\":" + "\"" + odb.getCustomerName() + "\"," + "\"programType\":"+ "\"" 
                    + odb.getProgramType() +"\"," + "\"oppoType\":"+ "\""
                    + odb.getOppType() +"\"," + "\"requestor\":"+ "\""
                    + odb.getRequestor() +"\"," + "\"oppOwner\":"+ "\""
                    + odb.getOppOwner() +"\"," + "\"primaryTSA\":"+ "\""
                    + odb.getPrimaryTSA() +"\"," + "\"market\":"+ "\""
                    + odb.getMktShortName() +"\"," + "\"geography\":"+ "\""
                    + odb.getGeoShortName() +"\"," + "\"region\":"+ "\""
                    + odb.getRegName() +"\"," + "\"country\":"+ "\""
                    + odb.getCountry()+ "\"" +  "}");
            if (i!=dataDDL.size()-1) {
                sb.append(",");


            }
        }

    }
    sb.append("]}");
    jsonObj=sb.toString();

    return jsonObj;
}
4

1 回答 1

0

看看Apache Poi

另外我建议使用json library

于 2013-04-01T08:00:49.677 回答