| | |
| | | rownum++; |
| | | } |
| | | } |
| | | //单体数据表 |
| | | createMonInfoSheet(wb, mon_vol_list, mon_tmp_list, groupinfo); |
| | | //单体数 |
| | | int monNum = mon_tmp_list.length; |
| | | //导出的总笔数 |
| | | int exportNum = groupinfo.size(); |
| | | //单体电压数据表(flag(0:单体电压,1:温度)) |
| | | createMonInfoSheet(wb, mon_vol_list, groupinfo, monNum, exportNum, 0); |
| | | //单体温度数据表 |
| | | createMonInfoSheet(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1); |
| | | //单体电压对比表-单体温度对比表 |
| | | createMonInfoSheet2(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic); |
| | | |
| | |
| | | return new BigDecimal(b).setScale(places, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | } |
| | | |
| | | public void createMonInfoSheet(HSSFWorkbook wb, String[][] mon_vol_list, String[][] mon_tmp_list, List<BatttestdataId> groupinfo) { |
| | | public void createMonInfoSheet(HSSFWorkbook wb, String[][] datalist, List<BatttestdataId> groupinfo, int monNum, int exportNum, int flag) { |
| | | String lang = ActionUtil.getLang(); |
| | | HSSFSheet sheet = null; |
| | | if (lang.contains("zh")) { |
| | | sheet = wb.createSheet("单体数据表"); |
| | | if (flag == 0) { |
| | | sheet = wb.createSheet("单体电压表"); |
| | | } else { |
| | | sheet = wb.createSheet("单体温度表"); |
| | | } |
| | | } else { |
| | | sheet = wb.createSheet("Individual Data Table"); |
| | | if (flag == 0) { |
| | | sheet = wb.createSheet("Voltage Data Table"); |
| | | } else { |
| | | sheet = wb.createSheet("Temperature Data Table"); |
| | | } |
| | | } |
| | | if (mon_vol_list != null && mon_tmp_list != null && groupinfo != null) { |
| | | int mon_count = mon_tmp_list.length; //总单体数量 |
| | | int total_col = mon_vol_list.length; //总记录条数 |
| | | |
| | | |
| | | if (datalist != null && groupinfo != null) { |
| | | /* int mon_count = mon_tmp_list.length; //总单体数量 |
| | | int total_col = mon_vol_list.length; //总记录条数*/ |
| | | List<String> tabTh = null; |
| | | if (lang.contains("zh")) { |
| | | tabTh = new ArrayList<String>() {{ |
| | |
| | | this.add("Test capacity(AH)"); |
| | | }}; |
| | | } |
| | | for (int i = 1; i <= mon_count; i++) { |
| | | for (int i = 1; i <= monNum; i++) { |
| | | if (lang.contains("zh")) { |
| | | tabTh.add("单体电压" + i + "(V)"); |
| | | if (flag == 0) { |
| | | tabTh.add("单体电压" + i + "(V)"); |
| | | } else { |
| | | tabTh.add("单体温度" + i + "(℃)"); |
| | | } |
| | | } else { |
| | | tabTh.add("Individual voltage" + i + "(V)"); |
| | | if (flag == 0) { |
| | | tabTh.add("Individual voltage" + i + "(V)"); |
| | | } else { |
| | | tabTh.add("Monomer temperature" + i + "(V)"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | for (int i = 0; i <= mon_count; i++) { |
| | | /*for (int i = 0; i <= monNum; i++) { |
| | | if (i == 0) { |
| | | tabTh.add(""); |
| | | continue; |
| | |
| | | tabTh.add("Monomer temperature" + i + "(V)"); |
| | | } |
| | | |
| | | } |
| | | }*/ |
| | | |
| | | String[][] datas = new String[total_col][tabTh.size()]; |
| | | String[][] datas = new String[exportNum][tabTh.size()]; |
| | | |
| | | //System.out.println("datas.length"+datas.length+"\t datas[0].length:"+datas[0].length+"==mon_vol_list.length:"+mon_vol_list.length+"\tmon_vol_list[0].length"+mon_vol_list[0].length+"\tmon_tmp:"+mon_tmp_list[0].length); |
| | | |
| | | |
| | | for(int j=0;j < datas.length;j++){ |
| | | for (int j = 0; j < datas.length; j++) { |
| | | int currnum = 0; |
| | | datas[j][currnum++] = formatTestLong(groupinfo.get(j).getTestTimelong()); |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getOnlineVol(),2)+""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getGroupVol(),2)+""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCurr(),1)+""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCap(),1)+""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getOnlineVol(), 2) + ""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getGroupVol(), 2) + ""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCurr(), 1) + ""; |
| | | datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCap(), 1) + ""; |
| | | |
| | | for(int i=0;i<mon_vol_list[j].length;i++){ |
| | | datas[j][currnum++] = mon_vol_list[j][i]; |
| | | if (flag == 0) { |
| | | for (int i = 0; i < monNum; i++) { |
| | | datas[j][currnum++] = datalist[j][i]; |
| | | } |
| | | } else { |
| | | for (int i = 0; i < monNum; i++) { |
| | | datas[j][currnum++] = datalist[i][j]; |
| | | } |
| | | } |
| | | datas[j][currnum++] = ""; |
| | | for(int i=0;i<mon_tmp_list.length;i++){ |
| | | datas[j][currnum++] = mon_tmp_list[i][j]; |
| | | } |
| | | //datas[j][currnum++] = ""; |
| | | } |
| | | //System.out.println("mon_vol_list"+mon_vol_list.length+"\t mon_tmp_list:"+mon_tmp_list.length); |
| | | |
| | | int maxcol = 254; //设置最大列数 |
| | | int maxcol = 254; //设置最大列数 |
| | | |
| | | int countReLine = (int) Math.ceil((double)total_col/maxcol); |
| | | int totalrow = countReLine *(tabTh.size()+1); //excel总行数 |
| | | for(int i=0;i<totalrow;i++){ |
| | | int countReLine = (int) Math.ceil((double) exportNum / maxcol); |
| | | int totalrow = countReLine * (tabTh.size() + 1); //excel总行数 |
| | | for (int i = 0; i < totalrow; i++) { |
| | | sheet.createRow(i); |
| | | } |
| | | |
| | | //System.out.println("countReLine:"+countReLine); |
| | | |
| | | int currRow = 0; //当前行 |
| | | int arr_index = 0; //当前列 |
| | | for(int i=0;i<countReLine;i++){ |
| | | for(int col = 0;col <= maxcol && col<=datas.length && arr_index<datas.length;col++){ |
| | | if(col == 0){ |
| | | for(int k=0;k<tabTh.size();k++){ |
| | | sheet.getRow(k+currRow).createCell(col).setCellValue(tabTh.get(k)); |
| | | int currRow = 0; //当前行 |
| | | int arr_index = 0; //当前列 |
| | | for (int i = 0; i < countReLine; i++) { |
| | | for (int col = 0; col <= maxcol && col <= datas.length && arr_index < datas.length; col++) { |
| | | if (col == 0) { |
| | | for (int k = 0; k < tabTh.size(); k++) { |
| | | sheet.getRow(k + currRow).createCell(col).setCellValue(tabTh.get(k)); |
| | | } |
| | | }else{ |
| | | for(int k = 0;k<datas[arr_index].length;k++){ |
| | | sheet.getRow(k+currRow).createCell(col).setCellValue(datas[arr_index][k]); |
| | | } else { |
| | | for (int k = 0; k < datas[arr_index].length; k++) { |
| | | sheet.getRow(k + currRow).createCell(col).setCellValue(datas[arr_index][k]); |
| | | } |
| | | arr_index++; |
| | | } |
| | | } |
| | | currRow += tabTh.size()+1; |
| | | currRow += tabTh.size() + 1; |
| | | } |
| | | |
| | | //System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length); |