'123'
This commit is contained in:
parent
e90bde476a
commit
8e37de0c7a
|
@ -171,7 +171,7 @@ public @interface Excel
|
||||||
|
|
||||||
public enum ColumnType
|
public enum ColumnType
|
||||||
{
|
{
|
||||||
NUMERIC(0), STRING(1), IMAGE(2);
|
NUMERIC(0), STRING(1), IMAGE(2), TEXT(3);
|
||||||
private final int value;
|
private final int value;
|
||||||
|
|
||||||
ColumnType(int value)
|
ColumnType(int value)
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class SysUser extends BaseEntity
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/** 手机号码 */
|
/** 手机号码 */
|
||||||
@Excel(name = "手机号码")
|
@Excel(name = "手机号码", cellType = ColumnType.TEXT)
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
|
|
||||||
/** 用户性别 */
|
/** 用户性别 */
|
||||||
|
|
|
@ -34,27 +34,7 @@ import org.apache.poi.hssf.usermodel.HSSFShape;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
||||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.CellStyle;
|
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
|
||||||
import org.apache.poi.ss.usermodel.ClientAnchor;
|
|
||||||
import org.apache.poi.ss.usermodel.DataValidation;
|
|
||||||
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
|
||||||
import org.apache.poi.ss.usermodel.DataValidationHelper;
|
|
||||||
import org.apache.poi.ss.usermodel.DateUtil;
|
|
||||||
import org.apache.poi.ss.usermodel.Drawing;
|
|
||||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
|
||||||
import org.apache.poi.ss.usermodel.Font;
|
|
||||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
||||||
import org.apache.poi.ss.usermodel.Name;
|
|
||||||
import org.apache.poi.ss.usermodel.PictureData;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
|
@ -884,6 +864,11 @@ public class ExcelUtil<T>
|
||||||
dataFont.setFontHeightInPoints((short) 10);
|
dataFont.setFontHeightInPoints((short) 10);
|
||||||
dataFont.setColor(excel.color().index);
|
dataFont.setColor(excel.color().index);
|
||||||
style.setFont(dataFont);
|
style.setFont(dataFont);
|
||||||
|
if (ColumnType.TEXT == excel.cellType())
|
||||||
|
{
|
||||||
|
DataFormat dataFormat = wb.createDataFormat();
|
||||||
|
style.setDataFormat(dataFormat.getFormat("@"));
|
||||||
|
}
|
||||||
styles.put(key, style);
|
styles.put(key, style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -922,7 +907,7 @@ public class ExcelUtil<T>
|
||||||
*/
|
*/
|
||||||
public void setCellVo(Object value, Excel attr, Cell cell)
|
public void setCellVo(Object value, Excel attr, Cell cell)
|
||||||
{
|
{
|
||||||
if (ColumnType.STRING == attr.cellType())
|
if (ColumnType.STRING == attr.cellType()|| ColumnType.TEXT == attr.cellType())
|
||||||
{
|
{
|
||||||
String cellValue = Convert.toStr(value);
|
String cellValue = Convert.toStr(value);
|
||||||
// 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。
|
// 对于任何以表达式触发字符 =-+@开头的单元格,直接使用tab字符作为前缀,防止CSV注入。
|
||||||
|
|
Loading…
Reference in New Issue