public class JxlsExcelUtil extends Object
| 构造器和说明 |
|---|
JxlsExcelUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
private static void |
addComment(org.apache.poi.ss.usermodel.Cell cell,
String value,
ExcelTypeEnum excelType)
给Cell添加批注
|
private static Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.Cell>> |
createAllCell(Map<Integer,org.apache.poi.ss.usermodel.Row> mapAllRows,
ExcelMapping mapping)
初始化创建所有列
|
private static Map<Integer,org.apache.poi.ss.usermodel.Row> |
createAllRow(org.apache.poi.ss.usermodel.Sheet sheet,
ExcelMapping mapping)
初始化创建所有行
|
private static Element |
createElementLoop(Document xml,
ExcelMappingLoop mappingLoop)
创建Loop元素
|
private static Element |
createExclusionSection(Document xml,
Integer startRow,
Integer endRow)
创建排除(占位)Section元素
排除(跳过)真实数据起始行前面的行数(如果不跳过非真实数据行,则会出现脏数据,loop即会把非真实数据行读取进来)
|
static org.springframework.web.multipart.MultipartFile |
createExportTemplate(ExcelMapping mapping)
创建导出模板
|
static org.springframework.web.multipart.MultipartFile |
createExportTemplate(org.springframework.web.multipart.MultipartFile templateFile,
ExcelMapping mapping)
创建导出模板
|
static Document |
createImportXml(ExcelMapping mapping)
创建导入模板xml文档
|
static org.springframework.web.multipart.MultipartFile |
createImportXmlToMultipartFile(ExcelMapping mapping)
创建导入模板xml文档
|
static org.springframework.web.multipart.MultipartFile |
delRow(org.springframework.web.multipart.MultipartFile file,
Integer sheetIndex,
List<Integer> lstRow)
删除指定行
|
static org.springframework.web.multipart.MultipartFile |
delWithExclusionRow(org.springframework.web.multipart.MultipartFile file,
Integer sheetIndex,
Integer startRow,
List<Integer> lstExclusionRow)
删除行(从指定起始行开始,删除排除行集合之外的所有行数据)
|
static String |
doubleToDate(Double date)
double to date
|
static byte[] |
exportExcel(byte[] templateFile,
Object mapperObject,
Object mapperLoop,
Object mapperFunc)
导出Excel(输出到本地)
|
static void |
exportExcel(byte[] templateFile,
Object mapperObject,
Object mapperLoop,
Object mapperFunc,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request)
导出Excel(输出到数据流)
|
static byte[] |
exportExcel(File templateFile,
File exportFile,
Object mapperObject,
Object mapperLoop,
Object mapperFunc)
导出Excel
|
static byte[] |
exportExcel(String templateFilePath,
Object mapperObject,
Object mapperLoop,
Object mapperFunc)
导出Excel(输出到本地)
|
static void |
exportExcel(String templateFilePath,
Object mapperObject,
Object mapperLoop,
Object mapperFunc,
javax.servlet.http.HttpServletResponse response,
javax.servlet.http.HttpServletRequest request)
导出Excel(输出到数据流)
|
static org.springframework.web.multipart.MultipartFile |
exportExcelToMultiPartFile(byte[] templateFile,
Object mapperObject,
Object mapperLoop,
Object mapperFunc)
导出Excel
|
static org.springframework.web.multipart.MultipartFile |
exportExcelToMultiPartFile(File templateFile,
File exportFile,
Object mapperObject,
Object mapperLoop,
Object mapperFunc)
导出Excel
|
Object |
formatDate(Date dt) |
static String |
getCellValueByCell(org.apache.poi.ss.usermodel.Cell cell)
获取单元格各类型值,返回字符串类型
|
static List<ExcelReadException> |
getReadExceptions(org.jxls.reader.XLSReadStatus xlsReadStatus)
解释Excel读取映射异常信息
|
private static void |
getSheetStyle(org.apache.poi.ss.usermodel.Sheet sheet,
Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.CellStyle>> mapAllStyle,
Map<Integer,Short> mapAllHeight,
Map<Integer,Integer> mapAllWidth)
获取所有单元格样式
|
static ExcelMapping |
getTemplateFileMaxRowAndCol(org.springframework.web.multipart.MultipartFile templateFile) |
String |
getTitle() |
static org.jxls.reader.XLSReadStatus |
importExcel(InputStream isImportFile,
InputStream isImportXmlTemplate,
Object items,
Boolean skipErrs)
导入Excel
|
static org.jxls.reader.XLSReadStatus |
importExcel(org.springframework.web.multipart.MultipartFile file,
byte[] templateFile,
Object items,
Boolean skipErrs)
导入Excel
|
static org.jxls.reader.XLSReadStatus |
importExcel(org.springframework.web.multipart.MultipartFile file,
String templateFilePath,
Object items,
Boolean skipErrs)
导入Excel
|
static org.jxls.reader.XLSReadStatus |
importExcel(String importFilePath,
byte[] templateFile,
Object items,
Boolean skipErrs)
导入Excel
|
static org.jxls.reader.XLSReadStatus |
importExcel(String importFilePath,
String templateFilePath,
Object items,
Boolean skipErrs)
导入Excel
|
org.jxls.transform.poi.WritableCellValue |
myLink(String address,
String title) |
static List<ExcelFieldInfo> |
readExcelByRow(org.springframework.web.multipart.MultipartFile file,
Integer sheetIdx,
Integer row)
读取excel文件指定行的字段信息
|
private static void |
setSheetStyle(org.apache.poi.ss.usermodel.Sheet sheet,
Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.CellStyle>> mapAllStyle)
设置工作表样式
|
private static void |
setSheetWidthHeight(org.apache.poi.ss.usermodel.Sheet sheet,
List<Short> lstRowHeight,
List<Short> lstColWidth)
设置工作表行高和列宽
https://zhidao.baidu.com/question/721783003339700525.html
|
private static void |
setSheetWidthHeight(org.apache.poi.ss.usermodel.Sheet sheet,
Map<Integer,Short> mapAllHeight,
Map<Integer,Integer> mapAllWidth)
设置工作表行高和列宽
https://zhidao.baidu.com/question/721783003339700525.html
|
Object |
timeChange(Long time) |
static String |
toDate(String val)
字符串转日期(double字符串转Date)
|
static String |
toDateDash(String val)
字符串转日期(double字符串转Date)
|
static String |
toDateSlash(String val)
字符串转日期(double字符串转Date)
|
public JxlsExcelUtil()
public static org.springframework.web.multipart.MultipartFile delWithExclusionRow(org.springframework.web.multipart.MultipartFile file, Integer sheetIndex, Integer startRow, List<Integer> lstExclusionRow)
file - sheetIndex - startRow - lstExclusionRow - public static org.springframework.web.multipart.MultipartFile delRow(org.springframework.web.multipart.MultipartFile file, Integer sheetIndex, List<Integer> lstRow)
file - sheetIndex - lstRow - public static org.jxls.reader.XLSReadStatus importExcel(org.springframework.web.multipart.MultipartFile file, String templateFilePath, Object items, Boolean skipErrs)
file - 待导入数据文件(Excel)templateFilePath - 导入模板文件路径items - 输出对象集合skipErrs - 是否跳过异常public static org.jxls.reader.XLSReadStatus importExcel(org.springframework.web.multipart.MultipartFile file, byte[] templateFile, Object items, Boolean skipErrs)
file - 待导入数据文件(Excel)templateFile - 导入模板二进制文件(如从数据库中读取的文件)items - 输出对象集合skipErrs - 是否跳过异常public static org.jxls.reader.XLSReadStatus importExcel(String importFilePath, String templateFilePath, Object items, Boolean skipErrs)
importFilePath - 待导入数据文件路径(Excel)templateFilePath - 导入模板文件路径items - 输出对象集合skipErrs - 是否跳过异常public static org.jxls.reader.XLSReadStatus importExcel(String importFilePath, byte[] templateFile, Object items, Boolean skipErrs)
importFilePath - 待导入数据文件路径(Excel)templateFile - 导入模板二进制文件(如从数据库中读取的文件)items - 输出对象集合skipErrs - 是否跳过异常public static org.jxls.reader.XLSReadStatus importExcel(InputStream isImportFile, InputStream isImportXmlTemplate, Object items, Boolean skipErrs)
isImportFile - 待导入数据文件流(Excel)isImportXmlTemplate - 载入的导入模板流items - 输出对象集合skipErrs - 是否跳过异常public static List<ExcelReadException> getReadExceptions(org.jxls.reader.XLSReadStatus xlsReadStatus)
xlsReadStatus - public static void exportExcel(String templateFilePath, Object mapperObject, Object mapperLoop, Object mapperFunc, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)
templateFilePath - Excel模板文件路径mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)response - request - public static void exportExcel(byte[] templateFile, Object mapperObject, Object mapperLoop, Object mapperFunc, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request)
templateFile - Excel模板二进制文件(从数据库中读取的)mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)response - request - public static byte[] exportExcel(String templateFilePath, Object mapperObject, Object mapperLoop, Object mapperFunc)
templateFilePath - Excel模板文件路径: xx/xxx/xxx.xlsxmapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)public static byte[] exportExcel(byte[] templateFile, Object mapperObject, Object mapperLoop, Object mapperFunc)
templateFile - Excel模板二进制文件(从数据库中读取的)mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)public static byte[] exportExcel(File templateFile, File exportFile, Object mapperObject, Object mapperLoop, Object mapperFunc)
templateFile - Excel模板文件exportFile - 输出文件mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)public static org.springframework.web.multipart.MultipartFile exportExcelToMultiPartFile(byte[] templateFile, Object mapperObject, Object mapperLoop, Object mapperFunc)
templateFile - Excel模板二进制文件(从数据库中读取的)mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)public static org.springframework.web.multipart.MultipartFile exportExcelToMultiPartFile(File templateFile, File exportFile, Object mapperObject, Object mapperLoop, Object mapperFunc)
templateFile - Excel模板文件exportFile - 输出文件mapperObject - 待导出对象数据(单一对象Object)mapperLoop - 待导出的循环对象数据(对象Object数组)mapperFunc - 待载入的自定义对象(用于Excel中引用其对象中的方法)(单一对象Object)private static void addComment(org.apache.poi.ss.usermodel.Cell cell, String value, ExcelTypeEnum excelType)
cell - 单元格value - 批注内容excelType - 扩展名public static org.springframework.web.multipart.MultipartFile createExportTemplate(ExcelMapping mapping)
mapping - public static org.springframework.web.multipart.MultipartFile createExportTemplate(org.springframework.web.multipart.MultipartFile templateFile, ExcelMapping mapping)
templateFile - 模板excel文件(主要取其样式,在原样式上生成新的模板)mapping - 映射数据public static ExcelMapping getTemplateFileMaxRowAndCol(org.springframework.web.multipart.MultipartFile templateFile)
private static void getSheetStyle(org.apache.poi.ss.usermodel.Sheet sheet, Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.CellStyle>> mapAllStyle, Map<Integer,Short> mapAllHeight, Map<Integer,Integer> mapAllWidth)
sheet - private static void setSheetStyle(org.apache.poi.ss.usermodel.Sheet sheet, Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.CellStyle>> mapAllStyle)
sheet - mapAllStyle - private static void setSheetWidthHeight(org.apache.poi.ss.usermodel.Sheet sheet, Map<Integer,Short> mapAllHeight, Map<Integer,Integer> mapAllWidth)
sheet - private static void setSheetWidthHeight(org.apache.poi.ss.usermodel.Sheet sheet, List<Short> lstRowHeight, List<Short> lstColWidth)
sheet - lstRowHeight - lstColWidth - private static Map<Integer,org.apache.poi.ss.usermodel.Row> createAllRow(org.apache.poi.ss.usermodel.Sheet sheet, ExcelMapping mapping)
sheet - mapping - private static Map<Integer,Map<Integer,org.apache.poi.ss.usermodel.Cell>> createAllCell(Map<Integer,org.apache.poi.ss.usermodel.Row> mapAllRows, ExcelMapping mapping)
mapAllRows - mapping - public static org.springframework.web.multipart.MultipartFile createImportXmlToMultipartFile(ExcelMapping mapping)
mapping - public static Document createImportXml(ExcelMapping mapping)
mapping - private static Element createElementLoop(Document xml, ExcelMappingLoop mappingLoop)
xml - mappingLoop - private static Element createExclusionSection(Document xml, Integer startRow, Integer endRow)
xml - startRow - endRow - public static List<ExcelFieldInfo> readExcelByRow(org.springframework.web.multipart.MultipartFile file, Integer sheetIdx, Integer row)
file - excel文件sheetIdx - sheet索引(0开始)row - 字段名所在行数public static String getCellValueByCell(org.apache.poi.ss.usermodel.Cell cell)
cell - cellpublic static String toDateDash(String val)
val - public static String doubleToDate(Double date)
date - public static String toDateSlash(String val)
val - public Object formatDate(Date dt)
public Object timeChange(Long time)
Copyright © 2024. All rights reserved.