Commit 76d40b8d by wangweidong

土工平台修改

parent dc371367
package com.patzn.cloud.service.lims.common;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
......@@ -487,13 +488,10 @@ public class HSSFWorkbookUtil {
int num = row.getLastCellNum();
for(int i=0;i<num;i++) {
XSSFCell cell= row.getCell(i);
if(cell!=null) {
cell.setCellType(CellType.STRING);
}
if(cell==null || cell.getStringCellValue()==null) {
if(cell==null || StringUtils.isBlank(getJavaValue(cell).toString())) {
continue;
}
String value= cell.getStringCellValue();
String value= getJavaValue(cell).toString();
if(!"".equals(value)) {
Set<String> keySet = item.keySet();
Iterator<String> it = keySet.iterator();
......
......@@ -317,6 +317,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
mapReplace.put("#{reportCode}",entrust.getEntrustCode());
List<SoilOriginalTemplateConfig> configList = soilOriginalTemplateConfigService.list(Condition.create().eq("template_id",templateId));
if (null==template.getMoreSheet() || 0 == template.getMoreSheet()){
logger.error("----------------------3");
......@@ -332,7 +333,7 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
if (null != beginRow
&& null!=template.getSampleMergerNum()
&& null!=template.getTemplateSampleNum()){
List<SoilOriginalTemplateConfig> configList = soilOriginalTemplateConfigService.list(Condition.create().eq("template_id",templateId));
int templateSampleNum = template.getTemplateSampleNum();
if (voList.size()<templateSampleNum){
int sampleMergerNum = template.getSampleMergerNum();
......@@ -587,32 +588,58 @@ public class SoilExperimentServiceImpl extends BaseServiceImpl<SoilExperimentMap
}
}else{
int index = 0;
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
int rowNum = xssfSheet.getLastRowNum();
xssfSheet.setForceFormulaRecalculation(true);
// int rowNum = xssfSheet.getLastRowNum();
//
// for (int i = 0; i < rowNum ; i++) {
// XSSFRow row = xssfSheet.getRow(i);
//
// int cellNum = row.getLastCellNum();
// for (int j = 0; j < cellNum; j++) {
// XSSFCell cell = row.getCell(j);
// if (cell.getCellType().equals(CellType.FORMULA)){
// String formula = cell.getCellFormula();
// if (StringUtils.isNotBlank(formula)){
// cell.setCellFormula(formula);
// }
// }
// }
// }
//
// xssfSheet.setForceFormulaRecalculation(true);
for (int i = 0; i < rowNum ; i++) {
XSSFRow row = xssfSheet.getRow(i);
int cellNum = row.getLastCellNum();
for (int j = 0; j < cellNum; j++) {
XSSFCell cell = row.getCell(j);
if (cell.getCellType().equals(CellType.FORMULA)){
String formula = cell.getCellFormula();
if (StringUtils.isNotBlank(formula)){
cell.setCellFormula(formula);
for (SoilOriginalTemplateConfig config:configList) {
if(StringUtils.isBlank(config.getFormula())){
continue;
}
if (null == config.getMergeRowNum()){
continue;
}
if (null == config.getColumnPlace()){
continue;
}
XSSFRow xssfRow = xssfSheet.getRow(config.getMergeRowNum());
if (null == xssfRow){
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if (null == cell){
continue;
}
cell.setCellFormula(config.getFormula());
}
xssfSheet.setForceFormulaRecalculation(true);
int index = 0;
for (SoilExperimentVO vo:voList) {
if (index==0){
xssfWorkbook.setSheetName(index,vo.getSampleCode());
xssfWorkbook.setSheetName(0,vo.getSampleCode());
index++;
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment