更换prompt名称

dep_wangsr
RuoYi 6 years ago committed by Limy
parent 4da966328f
commit 372a56e49e

@ -9,8 +9,6 @@ import com.ruoyi.common.reflect.ReflectUtils;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.apache.poi.hssf.usermodel.DVConstraint;
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.HSSFColor.HSSFColorPredefined;
@ -20,7 +18,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -329,7 +326,7 @@ public class ExcelUtil<T>
if (attr.combo().length > 0)
{
// 这里默认设了2-101列只能选择不能输入.
setHSSFValidation(sheet, attr.combo(), 1, 100, i, i);
setXSSFValidation(sheet, attr.combo(), 1, 100, i, i);
}
}
if (Type.EXPORT.equals(type))
@ -422,11 +419,11 @@ public class ExcelUtil<T>
Object value = getTargetValue(vo, field, attr);
String dateFormat = attr.dateFormat();
String readConverterExp = attr.readConverterExp();
if (StringUtils.isNotEmpty(dateFormat))
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
{
cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value));
}
else if (StringUtils.isNotEmpty(readConverterExp))
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
{
cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp));
}
@ -440,40 +437,15 @@ public class ExcelUtil<T>
}
catch (Exception e)
{
log.error("导出Excel失败{}", e.getMessage());
log.error("导出Excel失败{}", e);
}
}
}
}
/**
*
*
* @param sheet sheet.
* @param promptTitle
* @param promptContent
* @param firstRow
* @param endRow
* @param firstCol
* @param endCol
* @return sheet.
*/
public static Sheet setHSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
int firstCol, int endCol)
{
// 构造constraint对象
DVConstraint constraint = DVConstraint.createCustomFormulaConstraint("DD1");
// 四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
HSSFDataValidation dataValidationView = new HSSFDataValidation(regions, constraint);
dataValidationView.createPromptBox(promptTitle, promptContent);
sheet.addValidationData(dataValidationView);
return sheet;
}
/**
* POI XSSFSheet
*
* @param sheet
* @param promptTitle
* @param promptContent
@ -482,11 +454,13 @@ public class ExcelUtil<T>
* @param firstCol
* @param endCol
*/
public static void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, int firstCol, int endCol) {
DataValidationHelper dvHelper = sheet.getDataValidationHelper();
DataValidationConstraint constraint = dvHelper.createCustomConstraint("*");
public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
int firstCol, int endCol)
{
DataValidationHelper helper = sheet.getDataValidationHelper();
DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
DataValidation dataValidation = dvHelper.createValidation(constraint, regions);
DataValidation dataValidation = helper.createValidation(constraint, regions);
dataValidation.createPromptBox(promptTitle, promptContent);
dataValidation.setShowPromptBox(true);
sheet.addValidationData(dataValidation);
@ -503,8 +477,7 @@ public class ExcelUtil<T>
* @param endCol
* @return sheet.
*/
public static Sheet setHSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol,
int endCol)
public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol)
{
DataValidationHelper helper = sheet.getDataValidationHelper();
// 加载下拉列表内容
@ -525,7 +498,6 @@ public class ExcelUtil<T>
}
sheet.addValidationData(dataValidation);
return sheet;
}
/**

@ -5,7 +5,6 @@ import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.base.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List;
@ -19,7 +18,7 @@ public class SysUser extends BaseEntity
private static final long serialVersionUID = 1L;
/** 用户ID */
@Excel(name = "用户序号", prompt = "用户流水号")
@Excel(name = "用户序号", prompt = "用户号")
private Long userId;
/** 部门ID */

Loading…
Cancel
Save