Excel导入poi、导出poi

依赖Jar包

<!-- 处理Excel2003 -->
<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.17</version>
</dependency>
<!-- 处理Excel2007 -->
<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.17</version>
</dependency>

ExcelSheetPO.java

package com.yujiantong.util.excel;
import java.util.List;
/*** 定义表格的数据对象* @date 2019年01月20日*/
public class ExcelSheetPO {/*** sheet的名称*/private String sheetName;/*** 表格标题*/private String title;/*** 头部标题集合*/private String[] headers;/*** 数据集合*/private List<List<Object>> dataList;public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String[] getHeaders() {return headers;}public void setHeaders(String[] headers) {this.headers = headers;}public List<List<Object>> getDataList() {return dataList;}public void setDataList(List<List<Object>> dataList) {this.dataList = dataList;}public String getSheetName() {return sheetName;}public void setSheetName(String sheetName) {this.sheetName = sheetName;}
}

ExcelVersion.java

package com.yujiantong.util.excel;
/*** excel版本枚举* * @date 2019年01月20日*/
public enum ExcelVersion {/*** 虽然V2007版本支持最大支持1048575 * 16383 , * V2003版支持65535*255* 但是在实际应用中如果使用如此庞大的对象集合会导致内存溢出,* 因此这里限制最大为10000*100,如果还要加大建议先通过单元测试进行性能测试。* 1000*100 全部导出预计时间为27s左右*/V2003(".xls", 10000, 100), V2007(".xlsx", 100, 100);private String suffix;private int maxRow;private int maxColumn;ExcelVersion(String suffix, int maxRow, int maxColumn) {this.suffix = suffix;this.maxRow = maxRow;this.maxColumn = maxColumn;}public String getSuffix() {return this.suffix;}public int getMaxRow() {return maxRow;}public void setMaxRow(int maxRow) {this.maxRow = maxRow;}public int getMaxColumn() {return maxColumn;}public void setMaxColumn(int maxColumn) {this.maxColumn = maxColumn;}public void setSuffix(String suffix) {this.suffix = suffix;}
}

ImportExcelSheetUtil .java

package com.yujiantong.util.excel;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;import javax.servlet.http.HttpServletRequest;import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.locale.converters.DateLocaleConverter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellValue;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.WorkbookUtil;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bofu.bkp.po.fillin.CFillinAchievement;
import com.bofu.bkp.po.fillin.CFillinVehicle;
import com.bofu.bkp.po.fillin.CFillinVisit;
import com.bofu.bkp.service.store.StoreServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.diagnostics.logging.Logger;/*** excel工具类 提供读取和写入excel的功能* * @date 2019年01月20日*/
@SuppressWarnings("all")
public class ImportExcelSheetUtil {private final static String xls = "xls";private final static String xlsx = "xlsx";/*** 读取excel文件里面的内容 支持日期,数字,字符,函数公式,布尔类型* * @param file* @param rowCount* @param columnCount* @return* @throws FileNotFoundException* @throws IOException*/public static List<ExcelSheetPO> readExcel(MultipartFile file, Integer rowCount, Integer columnCount)throws FileNotFoundException, IOException {// 根据后缀名称判断excel的版本//String extName = FileUtil.getFileExtName(file);String extName = file.getOriginalFilename();Workbook wb = null;//获取excel文件的io流InputStream is = file.getInputStream();if (extName.endsWith(xls)) {wb = new HSSFWorkbook(is);} else if (extName.endsWith(xlsx)) {wb = new XSSFWorkbook(is);} else {// 无效后缀名称,这里之能保证excel的后缀名称,不能保证文件类型正确,不过没关系,在创建Workbook的时候会校验文件格式throw new IllegalArgumentException("Invalid excel version");}// 开始读取数据List<ExcelSheetPO> sheetPOs = new ArrayList<>();// 解析sheetfor (int i = 0; i < wb.getNumberOfSheets(); i++) {Sheet sheet = wb.getSheetAt(i);List<List<Object>> dataList = new ArrayList<>();ExcelSheetPO sheetPO = new ExcelSheetPO();sheetPO.setSheetName(sheet.getSheetName());sheetPO.setDataList(dataList);int readRowCount = 0;if (rowCount == null || rowCount > sheet.getPhysicalNumberOfRows()) {readRowCount = sheet.getPhysicalNumberOfRows();} else {readRowCount = rowCount;}// 解析sheet 的行for (int j = sheet.getFirstRowNum(); j < readRowCount; j++) {Row row = sheet.getRow(j);if (row == null) {continue;}if (row.getFirstCellNum() < 0) {continue;}int readColumnCount = 0;if (columnCount == null || columnCount > row.getLastCellNum()) {readColumnCount = (int) row.getLastCellNum();} else {readColumnCount = columnCount;}List<Object> rowValue = new LinkedList<Object>();// 解析sheet 的列for (int k = 0; k < readColumnCount; k++) {Cell cell = row.getCell(k);rowValue.add(getCellValue(wb, cell));}dataList.add(rowValue);}sheetPOs.add(sheetPO);}return sheetPOs;}private static Object getCellValue(Workbook wb, Cell cell) {Object columnValue = null;if (cell != null) {switch (cell.getCellType()) {case Cell.CELL_TYPE_STRING:columnValue = cell.getStringCellValue();/*if("是".equals(columnValue)){columnValue = 1;}else if("否".equals(columnValue)){columnValue = 2;}else{columnValue = cell.getStringCellValue();}*/break;case Cell.CELL_TYPE_NUMERIC:if (HSSFDateUtil.isCellDateFormatted(cell)) {// 处理日期格式、时间格式SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化日期字符串Date date = cell.getDateCellValue();//columnValue = sdf.format(date);String format = sdf.format(date);  if(format.contains("1899")){SimpleDateFormat sd = new SimpleDateFormat("HH:mm:ss");// 格式化日期字符串columnValue = sd.format(date).toString();}else{columnValue = sdf.format(date);   }} else {double value = cell.getNumericCellValue();CellStyle style = cell.getCellStyle();DecimalFormat format = new DecimalFormat();String temp = style.getDataFormatString();// 单元格设置成常规if (temp.equals("General")) {format.applyPattern("#");}if(value % 1 == 0){// 是这个整数,小数点后面是0columnValue = format.format(value);}else{//不是整数,小数点后面不是0columnValue = value + "";//format.format(value);}if (columnValue.toString().indexOf(",") >= 0) {columnValue = columnValue.toString().replace(",", "");}}break;case Cell.CELL_TYPE_BOOLEAN:columnValue = cell.getBooleanCellValue();break;case Cell.CELL_TYPE_BLANK:columnValue = "";break;case Cell.CELL_TYPE_FORMULA:// 格式单元格FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();evaluator.evaluateFormulaCell(cell);CellValue cellValue = evaluator.evaluate(cell);columnValue = cellValue.getNumberValue();break;default:columnValue = cell.toString();}}return columnValue;}/*** 将list按行写入到txt文件中(一般导入数据时过滤出错的信息,写入文本)* @param strings* @param path* @throws Exception*/public static void writeFileContext(List<Map<String,Object>> errorMessage,HttpServletRequest request) throws Exception {String p = request.getSession().getServletContext().getRealPath("");String path ="/WEB-INF/static/message/erroMessage.txt";File file = new File(p+path);//如果没有文件就创建if (!file.isFile()) {file.createNewFile();}Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(p+path), "utf-8"));for (Map<String, Object> map : errorMessage) {String str = "第"+map.get("errorRow").toString()+"行:"+map.get("errorString").toString().trim();writer.write(str + "\r\n");}writer.flush();writer.close();}
}

以上三个类都是导入excel用到的,下面介绍excel导出时所用到的一个类

ExportExcelUtil.java

package com.tong.util;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.util.StringUtils;/*** 导出Excel* @author Tong** @param <T>*/
public class ExportExcelUtil<T>{// 2007 版本以上 最大支持1048576行public  final static String  EXCEl_FILE_2007 = "2007";// 2003 版本 最大支持65536 行public  final static String  EXCEL_FILE_2003 = "2003";/*** <p>* 导出无头部标题行Excel <br>* 时间格式默认:yyyy-MM-dd hh:mm:ss <br>* </p>* * @param title 表格标题* @param dataset 数据集合* @param out 输出流* @param version 2003 或者 2007,不传时默认生成2003版本*/public void exportExcel(String title, Collection<T> dataset, OutputStream out, String version) {if(StringUtils.isEmpty(version) || EXCEL_FILE_2003.equals(version.trim())){exportExcel2003(title, null, dataset, out, "yyyy-MM-dd HH:mm:ss");}else{exportExcel2007(title, null, dataset, out, "yyyy-MM-dd HH:mm:ss");}}/*** <p>* 导出带有头部标题行的Excel <br>* 时间格式默认:yyyy-MM-dd hh:mm:ss <br>* </p>* * @param title 表格标题* @param headers 头部标题集合* @param dataset 数据集合* @param out 输出流* @param version 2003 或者 2007,不传时默认生成2003版本*/public void exportExcel(String title,String[] headers, Collection<T> dataset, OutputStream out,String version) {if(StringUtils.isEmpty(version) || EXCEL_FILE_2003.equals(version.trim())){exportExcel2003(title, headers, dataset, out, "yyyy-MM-dd HH:mm:ss");}else{exportExcel2007(title, headers, dataset, out, "yyyy-MM-dd HH:mm:ss");}}/*** <p>* 通用Excel导出方法,利用反射机制遍历对象的所有字段,将数据写入Excel文件中 <br>* 此版本生成2007以上版本的文件 (文件后缀:xlsx)* </p>* * @param title*            表格标题名* @param headers*            表格头部标题集合* @param dataset*            需要显示的数据集合,集合中一定要放置符合JavaBean风格的类的对象。此方法支持的*            JavaBean属性的数据类型有基本数据类型及String,Date* @param out*            与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中* @param pattern*            如果有时间数据,设定输出格式。默认为"yyyy-MM-dd hh:mm:ss"*/@SuppressWarnings({ "unchecked", "rawtypes" })public void exportExcel2007(String title, String[] headers, Collection<T> dataset, OutputStream out, String pattern) {// 声明一个工作薄XSSFWorkbook workbook = new XSSFWorkbook();// 生成一个表格XSSFSheet sheet = workbook.createSheet(title);// 设置表格默认列宽度为15个字节sheet.setDefaultColumnWidth(20);// 生成一个样式XSSFCellStyle style = workbook.createCellStyle();// 设置这些样式style.setFillForegroundColor(new XSSFColor(java.awt.Color.gray));style.setFillPattern(FillPatternType.SOLID_FOREGROUND);style.setBorderBottom(BorderStyle.THIN);style.setBorderLeft(BorderStyle.THIN);style.setBorderRight(BorderStyle.THIN);style.setBorderTop(BorderStyle.THIN);style.setAlignment(HorizontalAlignment.CENTER);// 生成一个字体XSSFFont font = workbook.createFont();font.setBold(true);font.setFontName("宋体"); font.setColor(new XSSFColor(java.awt.Color.BLACK));font.setFontHeightInPoints((short) 13);// 把字体应用到当前的样式style.setFont(font);// 生成并设置另一个样式XSSFCellStyle style2 = workbook.createCellStyle();style2.setFillForegroundColor(new XSSFColor(java.awt.Color.WHITE));style2.setFillPattern(FillPatternType.SOLID_FOREGROUND);style2.setBorderBottom(BorderStyle.THIN);style2.setBorderLeft(BorderStyle.THIN);style2.setBorderRight(BorderStyle.THIN);style2.setBorderTop(BorderStyle.THIN);style2.setAlignment(HorizontalAlignment.CENTER);style2.setVerticalAlignment(VerticalAlignment.CENTER);// 生成另一个字体XSSFFont font2 = workbook.createFont();font2.setBold(false);// 把字体应用到当前的样式style2.setFont(font2);// 产生表格标题行XSSFRow row = sheet.createRow(0);XSSFCell cellHeader;for (int i = 0; i < headers.length; i++) {cellHeader = row.createCell(i);cellHeader.setCellStyle(style);cellHeader.setCellValue(new XSSFRichTextString(headers[i]));}// 遍历集合数据,产生数据行Iterator<T> it = dataset.iterator();int index = 0;T t;Field[] fields;Field field;XSSFRichTextString richString;Pattern p = Pattern.compile("^//d+(//.//d+)?$");Matcher matcher;String fieldName;String getMethodName;XSSFCell cell;Class tCls;Method getMethod;Object value;String textValue;SimpleDateFormat sdf = new SimpleDateFormat(pattern);while (it.hasNext()) {index++;row = sheet.createRow(index);t = (T) it.next();// 利用反射,根据JavaBean属性的先后顺序,动态调用getXxx()方法得到属性值fields = t.getClass().getDeclaredFields();for (int i = 0; i < fields.length; i++) {cell = row.createCell(i);cell.setCellStyle(style2);field = fields[i];fieldName = field.getName();getMethodName = "get" + fieldName.substring(0, 1).toUpperCase()+ fieldName.substring(1);try {tCls = t.getClass();getMethod = tCls.getMethod(getMethodName, new Class[] {});value = getMethod.invoke(t, new Object[] {});// 判断值的类型后进行强制类型转换textValue = null;if (value instanceof Integer) {cell.setCellValue((Integer) value);} else if (value instanceof Float) {textValue = String.valueOf((Float) value);cell.setCellValue(textValue);} else if (value instanceof Double) {textValue = String.valueOf((Double) value);cell.setCellValue(textValue);} else if (value instanceof Long) {cell.setCellValue((Long) value);}if (value instanceof Boolean) {textValue = "是";if (!(Boolean) value) {textValue = "否";}} else if (value instanceof Date) {textValue = sdf.format((Date) value);} else {// 其它数据类型都当作字符串简单处理if (value != null) {textValue = value.toString();}}if (textValue != null) {matcher = p.matcher(textValue);if (matcher.matches()) {// 是数字当作double处理cell.setCellValue(Double.parseDouble(textValue));} else {richString = new XSSFRichTextString(textValue);cell.setCellValue(richString);}}} catch (SecurityException e) {e.printStackTrace();} catch (NoSuchMethodException e) {e.printStackTrace();} catch (IllegalArgumentException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();} catch (InvocationTargetException e) {e.printStackTrace();} finally {// 清理资源}}}try {workbook.write(out);} catch (IOException e) {e.printStackTrace();}}/*** <p>* 通用Excel导出方法,利用反射机制遍历对象的所有字段,将数据写入Excel文件中 <br>* 此方法生成2003版本的excel,文件名后缀:xls <br>* </p>* * @param title*            表格标题名* @param headers*            表格头部标题集合* @param dataset*            需要显示的数据集合,集合中一定要放置符合JavaBean风格的类的对象。此方法支持的*            JavaBean属性的数据类型有基本数据类型及String,Date* @param out*            与输出设备关联的流对象,可以将EXCEL文档导出到本地文件或者网络中* @param pattern*            如果有时间数据,设定输出格式。默认为"yyyy-MM-dd hh:mm:ss"*/@SuppressWarnings({ "unchecked", "rawtypes" })public void exportExcel2003(String title, String[] headers, Collection<T> dataset, OutputStream out, String pattern) {// 声明一个工作薄HSSFWorkbook workbook = new HSSFWorkbook();// 生成一个表格HSSFSheet sheet = workbook.createSheet(title);// 设置表格默认列宽度为15个字节sheet.setDefaultColumnWidth(20);// 生成一个样式HSSFCellStyle style = workbook.createCellStyle();// 设置这些样式style.setFillForegroundColor(HSSFColor.GREY_50_PERCENT.index);style.setFillPattern(FillPatternType.SOLID_FOREGROUND);style.setBorderBottom(BorderStyle.THIN);style.setBorderLeft(BorderStyle.THIN);style.setBorderRight(BorderStyle.THIN);style.setBorderTop(BorderStyle.THIN);style.setAlignment(HorizontalAlignment.CENTER);// 生成一个字体HSSFFont font = workbook.createFont();font.setBold(true);font.setFontName("宋体"); font.setColor(HSSFColor.WHITE.index);font.setFontHeightInPoints((short) 13);// 把字体应用到当前的样式style.setFont(font);// 生成并设置另一个样式HSSFCellStyle style2 = workbook.createCellStyle();style2.setFillForegroundColor(HSSFColor.WHITE.index);style2.setFillPattern(FillPatternType.SOLID_FOREGROUND);style2.setBorderBottom(BorderStyle.THIN);style2.setBorderLeft(BorderStyle.THIN);style2.setBorderRight(BorderStyle.THIN);style2.setBorderTop(BorderStyle.THIN);style2.setAlignment(HorizontalAlignment.CENTER);style2.setVerticalAlignment(VerticalAlignment.CENTER);// 生成另一个字体HSSFFont font2 = workbook.createFont();font2.setBold(false);// 把字体应用到当前的样式style2.setFont(font2);// 产生表格标题行HSSFRow row = sheet.createRow(0);HSSFCell cellHeader;for (int i = 0; i < headers.length; i++) {cellHeader = row.createCell(i);cellHeader.setCellStyle(style);cellHeader.setCellValue(new HSSFRichTextString(headers[i]));}// 遍历集合数据,产生数据行Iterator<T> it = dataset.iterator();int index = 0;T t;Field[] fields;Field field;HSSFRichTextString richString;Pattern p = Pattern.compile("^//d+(//.//d+)?$");Matcher matcher;String fieldName;String getMethodName;HSSFCell cell;Class tCls;Method getMethod;Object value;String textValue;SimpleDateFormat sdf = new SimpleDateFormat(pattern);while (it.hasNext()) {index++;row = sheet.createRow(index);t = (T) it.next();// 利用反射,根据JavaBean属性的先后顺序,动态调用getXxx()方法得到属性值fields = t.getClass().getDeclaredFields();for (int i = 0; i < fields.length; i++) {cell = row.createCell(i);cell.setCellStyle(style2);field = fields[i];fieldName = field.getName();getMethodName = "get" + fieldName.substring(0, 1).toUpperCase()+ fieldName.substring(1);try {tCls = t.getClass();getMethod = tCls.getMethod(getMethodName, new Class[] {});value = getMethod.invoke(t, new Object[] {});// 判断值的类型后进行强制类型转换textValue = null;if (value instanceof Integer) {cell.setCellValue((Integer) value);} else if (value instanceof Float) {textValue = String.valueOf((Float) value);cell.setCellValue(textValue);} else if (value instanceof Double) {textValue = String.valueOf((Double) value);cell.setCellValue(textValue);} else if (value instanceof Long) {cell.setCellValue((Long) value);}if (value instanceof Boolean) {textValue = "是";if (!(Boolean) value) {textValue = "否";}} else if (value instanceof Date) {textValue = sdf.format((Date) value);} else {// 其它数据类型都当作字符串简单处理if (value != null) {textValue = value.toString();}}if (textValue != null) {matcher = p.matcher(textValue);if (matcher.matches()) {// 是数字当作double处理cell.setCellValue(Double.parseDouble(textValue));} else {richString = new HSSFRichTextString(textValue);cell.setCellValue(richString);}}} catch (SecurityException e) {e.printStackTrace();} catch (NoSuchMethodException e) {e.printStackTrace();} catch (IllegalArgumentException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();} catch (InvocationTargetException e) {e.printStackTrace();} finally {// 清理资源}}}try {workbook.write(out);} catch (IOException e) {e.printStackTrace();}}
}

Excel导入poi、导出poi相关推荐

  1. C# Excel导入、导出

    C# Excel导入.导出 本篇主要介绍C#的Excel导入.导出. 目录 1. 介绍:描述第三方类库NPOI以及Excel结构 2. Excel导入:介绍C#如何调用NPOI进行Excel导入,包含 ...

  2. 大数据量的Excel导入和导出

    大数据量的Excel导入和导出 涉及到的技术 poi:使用SXSSFWorkbook,对数据进行分页且批量写入到磁盘(可以是任何outputsteam),减少数据在内存中的存储 easyExcel:从 ...

  3. C# Excel导入与导出

    Excel的结构     1.Workbook工作簿(也就是文件)     2.Sheet(也就是一个表)     3.Row(也就是一个数据行)     4.Cell(单元格)     5.Valu ...

  4. 前端实现 Excel 导入和导出功能

    注意:Excel的导入.导出功能一般情况下都是服务端完成,这里只是记录一下前端实现方法,供小众场景使用. 这里的实现要依赖第三方库:xlsx. 兼容性:IE9+ 安装 xlsx npm i -S ht ...

  5. 使用POI和EasyExcel实现Excel导入和导出功能

    需求场景 开发中经常会设计到excel的处理,需求场景如下所示: 1.将用户信息导出为excel表格(导出数据) 2.将Excel表中的信息录入到数据库中(导入数据) 操作Excel目前比较流行的就是 ...

  6. POI实现Excel导入和导出(源码测试)

    简介: Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能. 注意: 1.HSSFworkbook对象导 ...

  7. 若依管理系统前后端分离版基于ElementUI和SpringBoot怎样实现Excel导入和导出

    场景 使用若依前后端分离版实现Excel的导入和导出. 前端:Vue+ElementUI 后端:SpringBoot+POI+Mysql 注: 博客: https://blog.csdn.net/ba ...

  8. Java Excel导入和导出(支持xls导入,xlsx导入,图片导出,百万数据量导出)

    免费源码下载(提取码:qdhy) 工程结构目录 所需JAR包 <dependencies><!-- JUNIT 测试 --><dependency><grou ...

  9. ThinkPHP6 的Excel导入与导出

    Excel导入导出功能我们经常用到,下面记录自己的实现方法.Helper类PHPExcelHelper 可以直接拿过来使用.在控制器中实现数据组装,model中实现数据验证,最后导入或导出. help ...

  10. C#Excel导入和导出

    Excel导入 一.在WEB中导入Excel的方法 方法1: 通过OleDB方式获取Excel文件的数据到DataSet中,然后将Dataset中的每笔记录插入到SQL Server using Sy ...

最新文章

  1. SUBSTRING函數用法
  2. linux的临时页表映射问题
  3. html不间断滚动图片,Javascript实现图片不间断滚动的代码
  4. rust的权限柜怎么做_潍坊装修知识~二胎家庭不做上下铺,把两张床靠墙放,中间做收纳柜,你感觉怎么样?...
  5. oracle组合数据类型,oracle复合数据类型-相关方法
  6. 【数据结构与算法】浅析堆栈以及数据结构的堆和栈
  7. Linux——VIM学习选取多行(转)
  8. 《Storm技术内幕与大数据实践》一第1章 绪论
  9. pycharm debug 单步调试太卡太慢解决方案
  10. win10 蓝牙搜不到设备怎么办
  11. 步进电机和伺服电机的区别
  12. Nginx 负载均衡演示之 upstream 参数、 location 参数等示例说明
  13. 电脑证书错误即上网站打不开提示证书错误
  14. 卢卡斯定理 Lucas
  15. DL之RefineNet:RefineNet和Light-Weight RefineNet算法的简介(论文介绍)、架构详解、案例应用等配图集合之详细攻略
  16. Java Web之Servlet的三大常用作用域对象及其使用方法
  17. 第二课 IDEA 的使用
  18. C语言/771.宝石与石头
  19. Python 爬取 201865 条《隐秘的角落》弹幕数据,发现看剧不如爬山?
  20. UEFI安装winserver 2008

热门文章

  1. C/C++实现三角函数的方法
  2. 类成员函数指针和普通函数指针
  3. getline()与cin.getline()函数用法详解
  4. WPS文字表格外计算功能配合书签使用公式轻松实现
  5. 移动端使用fiddler抓包步骤
  6. Sed 删除匹配行,匹配的字符用Shell变量替换,且变量里含有斜杠“/”时,无法删除 解决办法
  7. 动规(11)-踩方格
  8. 百度实习转正学长面经-Java常见面试题目和解答,值得收藏
  9. 安装 MySQL 最新版本
  10. excel 添加垂直竖向直线