目录

Excel与DataBase之间的导入导出

前段代码

Body部分

导包部分

Script部分

后端代码

Util工具层

ExcelUtil工具类

读取工具类

写入工具类

自定义注解类

Entity层

Controller层

Service层

Mapper层

XML层


Excel与DataBase之间的导入导出

先简单写一下,具体说明之后逐渐完善。

前段代码

Body部分

<template><el-col :span="4"><el-button type="primary" @click="addBtn" icon="el-icon-circle-plus">新增</el-button><el-button type="success" @click="exportBtn" icon="el-icon-download">导出</el-button><el-upload class="upload-demo" action="http://localhost:9999/mbs/client/importExcel" style="width: 5px ;margin-top: -32px;margin-left: 160px"><el-button size="small" type="primary">导入</el-button></el-upload></el-col>
</template>

导包部分

import Vue from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
Vue.use(VueAxios, axios);

Script部分

<script>importBtn() {var _this = this;axios.post('http://localhost:9999/mbs/client/importExcel').then(function (response) {_this.$message.success('导入成功!');_this.load();}).catch(function (error) {_this.$message.error('导入失败!');console.log(error);});},exportBtn() {window.location.href = 'http://localhost:9999/mbs/client/exportExcel';}
</script>

后端代码

Util工具层

ExcelUtil工具类

package com.member.util;import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddressList;import static org.apache.poi.ss.usermodel.CellType.STRING;/*** ExcelUtil工具类** @author 拾三先生* @since 2020-03-08 22:00:00*/
/** ExcelUtil工具类实现功能:* 导出时传入list<T>,即可实现导出为一个excel,其中每个对象T为Excel中的一条记录.* 导入时读取excel,得到的结果是一个list<T>.T是自己定义的对象.* 需要导出的实体对象只需简单配置注解就能实现灵活导出,通过注解您可以方便实现下面功能:* 1.实体属性配置了注解就能导出到excel中,每个属性都对应一列.* 2.列名称可以通过注解配置.* 3.导出到哪一列可以通过注解配置.* 4.鼠标移动到该列时提示信息可以通过注解配置.* 5.用注解设置只能下拉选择不能随意填写功能.* 6.用注解设置是否只导出标题而不导出内容,这在导出内容作为模板以供用户填写时比较实用.*/
public class ExcelUtil<T> {Class<T> clazz;public ExcelUtil(Class<T> clazz) {this.clazz = clazz;}public List<T> importExcel(String sheetName, InputStream input) {List<T> list = new ArrayList<T>();try {HSSFWorkbook workbook = new HSSFWorkbook(input);HSSFSheet sheet = workbook.getSheet(sheetName);if (!sheetName.trim().equals("")) {sheet = workbook.getSheet(sheetName);// 如果指定sheet名,则取指定sheet中的内容.}if (sheet == null) {sheet = workbook.getSheetAt(0); // 如果传入的sheet名不存在则默认指向第1个sheet.}int rows = sheet.getPhysicalNumberOfRows();if (rows > 0) {// 有数据时才处理Field[] allFields = clazz.getDeclaredFields();// 得到类的所有field.Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();// 定义一个map用于存放列的序号和field.for (Field field : allFields) {// 将有注解的field存放到map中.if (field.isAnnotationPresent(ExcelVOAttribute.class)) {ExcelVOAttribute attr = field.getAnnotation(ExcelVOAttribute.class);int col = getExcelCol(attr.column());// 获得列号// System.out.println(col + "====" + field.getName());field.setAccessible(true);// 设置类的私有字段属性可访问.fieldsMap.put(col, field);}}for (int i = 1; i < rows; i++) {// 从第2行开始取数据,默认第一行是表头.HSSFRow row = sheet.getRow(i);int cellNum = row.getPhysicalNumberOfCells();T entity = null;for (int j = 0; j < cellNum; j++) {HSSFCell cell = row.getCell(j);if (cell == null) {continue;}String value = "";switch (cell.getCellType()) {case NUMERIC: // 数字//如果为时间格式的内容if (HSSFDateUtil.isCellDateFormatted(cell)) {//注:format格式 yyyy-MM-dd hh:mm:ss 中小时为12小时制,若要24小时制,则把小h变为H即可,yyyy-MM-dd HH:mm:ssSimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");value = sdf.format(HSSFDateUtil.getJavaDate(cell.getNumericCellValue())).toString();break;} else {value = new DecimalFormat("0").format(cell.getNumericCellValue());}break;case STRING: // 字符串value = cell.getStringCellValue();break;case BOOLEAN: // Booleanvalue = cell.getBooleanCellValue() + "";break;case FORMULA: // 公式value = cell.getCellFormula() + "";break;case BLANK: // 空值value = "";break;case ERROR: // 故障value = "非法字符";break;default:value = "未知类型";break;}System.out.println(value);if (value.equals("")) {continue;}entity = (entity == null ? clazz.newInstance() : entity);// 如果不存在实例则新建.// System.out.println(cells[j].getContents());Field field = fieldsMap.get(j);// 从map中得到对应列的field.// 取得类型,并根据对象类型设置值.Class<?> fieldType = field.getType();if (String.class == fieldType) {field.set(entity, String.valueOf(value));} else if ((Integer.TYPE == fieldType)|| (Integer.class == fieldType)) {field.set(entity, Integer.parseInt(value));} else if ((Long.TYPE == fieldType)|| (Long.class == fieldType)) {field.set(entity, Long.valueOf(value));} else if ((Float.TYPE == fieldType)|| (Float.class == fieldType)) {field.set(entity, Float.valueOf(value));} else if ((Short.TYPE == fieldType)|| (Short.class == fieldType)) {field.set(entity, Short.valueOf(value));} else if ((Double.TYPE == fieldType)|| (Double.class == fieldType)) {field.set(entity, Double.valueOf(value));} else if (Character.TYPE == fieldType) {if ((value != null) && (value.length() > 0)) {field.set(entity, Character.valueOf(value.charAt(0)));}}}if (entity != null) {list.add(entity);}}}} catch (IOException e) {e.printStackTrace();} catch (InstantiationException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();} catch (IllegalArgumentException e) {e.printStackTrace();}return list;}/*** 对list数据源将其里面的数据导入到excel表单** @param sheetName 工作表的名称* @param sheetSize 每个sheet中数据的行数,此数值必须小于65536* @param output    java输出流*/public boolean exportExcel(List<T> list, String sheetName, int sheetSize,OutputStream output) {Field[] allFields = clazz.getDeclaredFields();// 得到所有定义字段List<Field> fields = new ArrayList<Field>();// 得到所有field并存放到一个list中.for (Field field : allFields) {if (field.isAnnotationPresent(ExcelVOAttribute.class)) {fields.add(field);}}HSSFWorkbook workbook = new HSSFWorkbook();// 产生工作薄对象// excel2003中每个sheet中最多有65536行,为避免产生错误所以加这个逻辑.if (sheetSize > 65536 || sheetSize < 1) {sheetSize = 65536;}double sheetNo = Math.ceil(list.size() / sheetSize);// 取出一共有多少个sheet.for (int index = 0; index <= sheetNo; index++) {HSSFSheet sheet = workbook.createSheet();// 产生工作表对象if (sheetNo == 0) {workbook.setSheetName(index, sheetName);} else {workbook.setSheetName(index, sheetName + index);// 设置工作表的名称.}HSSFRow row;HSSFCell cell;// 产生单元格row = sheet.createRow(0);// 产生一行// 写入各个字段的列头名称for (int i = 0; i < fields.size(); i++) {Field field = fields.get(i);ExcelVOAttribute attr = field.getAnnotation(ExcelVOAttribute.class);int col = getExcelCol(attr.column());// 获得列号cell = row.createCell(col);// 创建列cell.setCellType(STRING);// 设置列中写入内容为String类型cell.setCellValue(attr.name());// 写入列名// 如果设置了提示信息则鼠标放上去提示.if (!attr.prompt().trim().equals("")) {setHSSFPrompt(sheet, "", attr.prompt(), 1, 100, col, col);// 这里默认设了2-101列提示.}// 如果设置了combo属性则本列只能选择不能输入if (attr.combo().length > 0) {setHSSFValidation(sheet, attr.combo(), 1, 100, col, col);// 这里默认设了2-101列只能选择不能输入.}}int startNo = index * sheetSize;int endNo = Math.min(startNo + sheetSize, list.size());// 写入各条记录,每条记录对应excel表中的一行for (int i = startNo; i < endNo; i++) {row = sheet.createRow(i + 1 - startNo);T vo = (T) list.get(i); // 得到导出对象.for (int j = 0; j < fields.size(); j++) {Field field = fields.get(j);// 获得field.field.setAccessible(true);// 设置实体类私有属性可访问ExcelVOAttribute attr = field.getAnnotation(ExcelVOAttribute.class);try {// 根据ExcelVOAttribute中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.if (attr.isExport()) {cell = row.createCell(getExcelCol(attr.column()));// 创建cellcell.setCellType(STRING);cell.setCellValue(field.get(vo) == null ? "": String.valueOf(field.get(vo)));// 如果数据存在就填入,不存在填入空格.}} catch (IllegalArgumentException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();}}}}try {output.flush();workbook.write(output);output.close();return true;} catch (IOException e) {e.printStackTrace();System.out.println("Output is closed ");return false;}}/*** 将EXCEL中A,B,C,D,E列映射成0,1,2,3** @param col*/public static int getExcelCol(String col) {col = col.toUpperCase();// 从-1开始计算,字母重1开始运算。这种总数下来算数正好相同。int count = -1;char[] cs = col.toCharArray();for (int i = 0; i < cs.length; i++) {count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i);}return count;}/*** 设置单元格上提示** @param sheet         要设置的sheet.* @param promptTitle   标题* @param promptContent 内容* @param firstRow      开始行* @param endRow        结束行* @param firstCol      开始列* @param endCol        结束列* @return 设置好的sheet.*/public static HSSFSheet setHSSFPrompt(HSSFSheet 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 data_validation_view = new HSSFDataValidation(regions, constraint);data_validation_view.createPromptBox(promptTitle, promptContent);sheet.addValidationData(data_validation_view);return sheet;}/*** 设置某些列的值只能输入预制的数据,显示下拉框.** @param sheet    要设置的sheet.* @param textlist 下拉框显示的内容* @param firstRow 开始行* @param endRow   结束行* @param firstCol 开始列* @param endCol   结束列* @return 设置好的sheet.*/public static HSSFSheet setHSSFValidation(HSSFSheet sheet,String[] textlist, int firstRow, int endRow, int firstCol,int endCol) {// 加载下拉列表内容DVConstraint constraint = DVConstraint.createExplicitListConstraint(textlist);// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列CellRangeAddressList regions = new CellRangeAddressList(firstRow,endRow, firstCol, endCol);// 数据有效性对象HSSFDataValidation data_validation_list = new HSSFDataValidation(regions, constraint);sheet.addValidationData(data_validation_list);return sheet;}
}

读取工具类

package com.member.util;import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;import java.io.IOException;/*** PoiRead类** @author 拾三先生* @since 2020-03-08 22:00:00*/
public class PoiRead {public static void main(String[] args) throws IOException {//获取工作簿对象XSSFWorkbook Workbook = new XSSFWorkbook("D:\\Poi测试\\测试信息.xlsx");//获取工作表XSSFSheet sheet = Workbook.getSheetAt(0);//获取行/*for (Row row : sheet){//获取单元格for (Cell cell : row){String value =cell.getStringCellValue();System.out.println(value);}}*///开始索引 0 结束索引int lastRowNum = sheet.getLastRowNum();System.out.println(lastRowNum);for (int i = 0; i <= lastRowNum; i++) {XSSFRow row = sheet.getRow(i);if (row != null) {//short cellNum = row.getLastCellNum();for (int j = 0; j <= cellNum; j++) {XSSFCell cell = row.getCell(j);if (cell != null) {String stringCellValue = cell.getStringCellValue();System.out.println(stringCellValue);}}}}//释放资源Workbook.close();}
}

写入工具类

package com.member.util;import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;/*** WritePoi类** @author 拾三先生* @since 2020-03-08 22:00:00*/
public class WritePoi {public static void main(String[] args) throws IOException {//创建工作簿XSSFWorkbook workbook = new XSSFWorkbook();//创建工作表XSSFSheet sheet = workbook.createSheet("测试表一");//创建行XSSFRow row = sheet.createRow(0);XSSFRow row2 = sheet.createRow(1);//创建单元格row.createCell(0).setCellValue("拾三先生");row.createCell(1).setCellValue("拾三先生");row.createCell(2).setCellValue("拾三先生");row2.createCell(0).setCellValue("拾三先生");row2.createCell(1).setCellValue("拾三先生");row2.createCell(2).setCellValue("拾三先生");//输出流FileOutputStream out = new FileOutputStream("D:\\Poi测试\\工作簿1.xlsx");workbook.write(out);out.flush();//释放资源out.close();workbook.close();System.out.println("写入成功");}
}

自定义注解类

package com.member.util;import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;/*** 自定义注解类** @author 拾三先生* @since 2020-03-08 22:00:00*/
@Retention(RetentionPolicy.RUNTIME)
@Target({java.lang.annotation.ElementType.FIELD})
public @interface ExcelVOAttribute {/*** 导出到Excel中的名字.*/public abstract String name();/*** 配置列的名称,对应A,B,C,D....*/public abstract String column();/*** 提示信息*/public abstract String prompt() default "";/*** 设置只能选择不能输入的列内容.*/public abstract String[] combo() default {};/*** 是否导出数据,应对需求:有时我们需要导出一份模板,这是标需题要但内容需要用户手工填写.*/public abstract boolean isExport() default true;
}

Entity层

package com.member.entity;import com.member.util.ExcelVOAttribute;import java.io.Serializable;/*** Client实体类** @author 拾三先生* @since 2020-03-08 22:00:00*/
@Data
public class Client implements Serializable {private static final long serialVersionUID = -50299480580387180L;/*** 会员客户ID*/@ExcelVOAttribute(name = "id", column = "A")private Integer id;/*** 账号*/@ExcelVOAttribute(name = "用户名", column = "B")private String username;/*** 密码*/@ExcelVOAttribute(name = "密码", column = "C")private String password;/*** 盐值列*/@ExcelVOAttribute(name = "盐值", column = "D")private String pwSalt;/*** 账号状态(帐号启用状态:0->禁用;1->启用)*/@ExcelVOAttribute(name = "状态", column = "E")private Integer status;/*** (身份证,护照,军官证,台胞证,港澳台来往内地通行证)*/@ExcelVOAttribute(name = "idType", column = "F")private String idType;/*** 正面*/@ExcelVOAttribute(name = "正面", column = "G")private String pathFront;/*** 反面*/@ExcelVOAttribute(name = "反面", column = "H")private String pathReverse;/*** 客户名字*/@ExcelVOAttribute(name = "客户名字", column = "I")private String name;/*** 联系人*/private String contactName;/*** 联系电话*/private String contactPhone;/*** 联系地址*/private String contactAddress;/*** 驾照号*/@ExcelVOAttribute(name = "驾照号", column = "J")private String licenseNo;/*** 性别*/@ExcelVOAttribute(name = "性别", column = "K")private String sex;/*** 电话*/@ExcelVOAttribute(name = "手机号", column = "L")private String phoneNum;/*** 地址*/@ExcelVOAttribute(name = "地址", column = "M")private String address;/*** 邮箱*/@ExcelVOAttribute(name = "邮箱", column = "N")private String email;/*** 会员级别(普通,金卡,白金,钻石)*/@ExcelVOAttribute(name = "会员级别", column = "O")private Integer memberLevelId;/*** 账户余额*/@ExcelVOAttribute(name = "账户余额", column = "P")private Double accountBalance;/*** 积分*/private int integration;/*** 成长值*/private double growth;/*** 历史积分数量*/private Integer historyIntegration;/*** 微信返回ID*/private Integer openId;/*** 登录验证token*/private String token;/*** 头像*/private String headPic;/*** 会员等级*/private String levelname;/*** 在客户表中添加流水表的,金额amount相关字段,进行多表同时新增和回滚*/private double amount;}

Controller层

注:具体内容应该放在业务层的,之后再修改。

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;/*** 表格操作控制层** @author 拾三先生* @since 2020-03-08 22:00:00*/
@RestController
@RequestMapping("client")
@ApiOperation("信息导入导出类")
public class ClientController {@Resourceprivate ClientService clientService;/*** 将Excel表导入到数据库表** @return String */@PostMapping("importExcel")public String importExcel(@RequestParam("file") MultipartFile file) {InputStream is = null;try {// @RequestParam("file") MultipartFile file 是用来接收前端传递过来的文件is = file.getInputStream();//下面是自己测试/*is = new FileInputStream("D:\\Poi测试\\会员测试.xls");*/} catch (IOException e) {e.printStackTrace();}ExcelUtil excelUtil = new ExcelUtil(Client.class);List list = excelUtil.importExcel("用户信息", is);int n = 0;for (int i = 0; i < list.size(); i++) {Client client = (Client) list.get(i);System.out.println(client);n = clientService.insertBy(client);System.out.println("i值为:" + list.get(i));}if (n > 0) {return "success";}return "失败";}
}
    /*** 将数据库表导出到Excel表** @return String */@GetMapping("exportExcel")public String exportExcel(HttpServletResponse response) throws IOException {SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd hhmmss");String sheetName = "用户信息";// 初始化数据List<Client> clientList = clientService.selectListClient();FileOutputStream out = null;//获取配置文件中保存对应excel文件的路径,本地也可以直接写成F:excel/testExcelString folderPath = ResourceBundle.getBundle("application").getString("downloadFolder") + File.separator + "testExcel";System.out.println(folderPath);//创建上传文件目录File folder = new File(folderPath);//如果文件夹不存在创建对应的文件夹if (!folder.exists()) {folder.mkdirs();}//设置文件名String fileName = sdf1.format(new Date()) + sheetName + ".xls";// String savePath = folderPath + File.separator + fileName;response.setHeader("content-disposition","attachment;fileName=" + fileName);/* try {out = new FileOutputStream(savePath);*//*out = new FileOutputStream(response.getOutputStream());*//*} catch (FileNotFoundException e) {e.printStackTrace();}*/ExcelUtil<Client> util = new ExcelUtil<Client>(Client.class); // 创建工具类.util.exportExcel(clientList, sheetName, 65536, response.getOutputStream()); // 导出System.out.println("----执行完毕----------");// System.out.println(savePath);//返回文件保存全路径return fileName;}

Service层

/*** 表格操作服务接口** @author 拾三先生* @since 2020-11-17 18:40:01*/
public interface ClientService {/*** 查询所有用户*/List<Client> selectListClient();/*** 新增用户入库*/int insertBy(Client client);
}
/*** 表格操作实现类** @author 拾三先生* @since 2020-11-17 18:40:02*/
@Service("clientService")
public class ClientServiceImpl implements ClientService {@Resourceprivate ClientMapper clientMapper;/*** 查询所有用户*/@Overridepublic List<Client> selectListClient() {return clientMapper.selectListClient();}/*** 新增用户入库*/@Overridepublic int insertBy(Client client) {return clientMapper.insertBy(client);}
}

Mapper层

/*** 表格操作数据库访问层** @author 拾三先生* @since 2020-11-17 18:39:59*/
public interface ClientMapper {/*** 查询所有用户信息*/List<Client> selectListClient();/*** 新增用户入库*/int insertBy(Client client);
}

XML层

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.member.mapper.ClientMapper"><resultMap type="com.aaa.member.entity.Client" id="ClientMap"><result property="id" column="id" jdbcType="INTEGER"/><result property="username" column="username" jdbcType="VARCHAR"/><result property="password" column="password" jdbcType="VARCHAR"/><result property="pwSalt" column="pw_salt" jdbcType="VARCHAR"/><result property="status" column="status" jdbcType="INTEGER"/><result property="idType" column="id_type" jdbcType="VARCHAR"/><result property="pathFront" column="path_front" jdbcType="VARCHAR"/><result property="pathReverse" column="path_reverse" jdbcType="VARCHAR"/><result property="name" column="name" jdbcType="VARCHAR"/><result property="contactName" column="contact_name" jdbcType="VARCHAR"/><result property="contactPhone" column="contact_phone" jdbcType="VARCHAR"/><result property="contactAddress" column="contact_address" jdbcType="VARCHAR"/><result property="licenseNo" column="license_no" jdbcType="VARCHAR"/><result property="sex" column="sex" jdbcType="VARCHAR"/><result property="phoneNum" column="phone_num" jdbcType="VARCHAR"/><result property="address" column="address" jdbcType="VARCHAR"/><result property="email" column="email" jdbcType="VARCHAR"/><result property="memberLevelId" column="member_level_id" jdbcType="INTEGER"/><result property="accountBalance" column="Account_Balance" jdbcType="DOUBLE"/><result property="integration" column="integration" jdbcType="VARCHAR"/><result property="growth" column="growth" jdbcType="VARCHAR"/><result property="historyIntegration" column="history_integration" jdbcType="INTEGER"/><result property="openId" column="open_id" jdbcType="INTEGER"/><result property="token" column="token" jdbcType="VARCHAR"/><result property="headPic" column="head_pic" jdbcType="VARCHAR"/><result property="levelname" column="levelname" jdbcType="VARCHAR"/></resultMap><select id="selectListClient" resultMap="ClientMap">selectid, username, password, pw_salt, status, id_type, path_front, path_reverse, name, contact_name, contact_phone,contact_address, license_no, sex, phone_num, address, email, member_level_id, Account_Balance, integration,growth, history_integration, open_id, token, head_picfrom tb_client</select><insert id="insertBy">insert into tb_client<trim prefix="(" suffix=")" suffixOverrides=","><if test="username != null and username != ''">username,</if><if test="password != null and password != ''">password,</if><if test="pwSalt != null and pwSalt != ''">pw_salt,</if><if test="status != null">status,</if><if test="idType != null and idType != ''">id_type,</if><if test="pathFront != null and pathFront != ''">path_front,</if><if test="pathReverse != null and pathReverse != ''">path_reverse,</if><if test="name != null and name != ''">name,</if><if test="contactName != null and contactName != ''">contact_name,</if><if test="contactPhone != null and contactPhone != ''">contact_phone,</if><if test="contactAddress != null and contactAddress != ''">contact_address,</if><if test="licenseNo != null and licenseNo != ''">license_no,</if><if test="sex != null and sex != ''">sex,</if><if test="phoneNum != null and phoneNum != ''">phone_num,</if><if test="address != null and address != ''">address,</if><if test="email != null and email != ''">email,</if><if test="memberLevelId != null">member_level_id,</if><if test="accountBalance != null">Account_Balance,</if><if test="integration != null and integration != ''">integration,</if><if test="growth != null and growth != ''">growth,</if><if test="historyIntegration != null and historyIntegration != ''">history_integration,</if><if test="openId != null">open_id,</if><if test="token != null and token != ''">token,</if><if test="headPic != null and headPic != ''">head_pic,</if></trim>values<trim prefix="(" suffix=")" suffixOverrides=","><if test="username != null and username != ''">#{username,jdbcType=VARCHAR},</if><if test="password != null and password != ''">#{password,jdbcType=VARCHAR},</if><if test="pwSalt != null and pwSalt != ''">#{pwSalt,jdbcType=VARCHAR},</if><if test="status != null">#{status,jdbcType=INTEGER},</if><if test="idType != null and idType != ''">#{idType,jdbcType=VARCHAR},</if><if test="pathFront != null and pathFront != ''">#{pathFront,jdbcType=VARCHAR},</if><if test="pathReverse != null and pathReverse != ''">#{pathReverse,jdbcType=VARCHAR},</if><if test="name != null and name != ''">#{name,jdbcType=VARCHAR},</if><if test="contactName != null and contactName != ''">#{contactName,jdbcType=VARCHAR},</if><if test="contactPhone != null and contactPhone != ''">#{contactPhone,jdbcType=VARCHAR},</if><if test="contactAddress != null and contactAddress != ''">#{contactAddress,jdbcType=VARCHAR},</if><if test="licenseNo != null and licenseNo != ''">#{licenseNo,jdbcType=VARCHAR},</if><if test="sex != null and sex != ''">#{sex,jdbcType=VARCHAR},</if><if test="phoneNum != null and phoneNum != ''">#{phoneNum,jdbcType=VARCHAR},</if><if test="address != null and address != ''">#{address,jdbcType=VARCHAR},</if><if test="email != null and email != ''">#{email,jdbcType=VARCHAR},</if><if test="memberLevelId != null">#{memberLevelId,jdbcType=INTEGER},</if><if test="accountBalance != null">#{accountBalance,jdbcType=DOUBLE},</if><if test="integration != null and integration != ''">#{integration,jdbcType=VARCHAR},</if><if test="growth != null and growth != ''">#{growth,jdbcType=VARCHAR},</if><if test="historyIntegration != null and historyIntegration != ''">#{historyIntegration,jdbcType=VARCHAR},</if><if test="openId != null">#{openId,jdbcType=INTEGER},</if><if test="token != null and token != ''">#{token,jdbcType=VARCHAR},</if><if test="headPic != null and headPic != ''">#{headPic,jdbcType=VARCHAR},</if></trim></insert></mapper>

Excel与DataBase之间的导入导出相关推荐

  1. 仅用Python三行代码,实现数据库和excel之间的导入导出

    目录 一.前言 二.python代码 2.1 从MySQL数据库导入csv 2.2 从csv导入MySQL数据库 三.讲解视频 一.前言 之前我分享过两次python的高效编程技巧,分别是, pyth ...

  2. Excel与Sql Server互通导入导出跨语言

    目录 Excel与Sql Server互通导入导出跨语言 1.目标Excel缺少表的列标题字段 1.1.问题的提出从这里开始 1.2.参数的正确写法 1.3.附带说一下Jet 4.0 1.4.附带说一 ...

  3. Oracle导入到不同的角色,oracle 不同版本之间的导入导出

    不同版本oracle导入导出解决办法. 今天遇到一个比较特殊的情况,需要在oracle8中使用oracle9的数据,如是导入导出.费了大半天,从oracle9中导出的数据就是无法导入oracle8中. ...

  4. toad导入数据_利用TOAD实现EXCEL数据在oracle的导入导出

    利用TOAD实现EXCEL数据在oracle的导入导出 1.从ORACLE数据库导出成为EXCEL文件 利用TOAD连接上数据库,访问某个表,我本机是选中表"OA_USER" 右键 ...

  5. 轻松实现SQL Server与Access、Excel数据表间的导入导出

    在SQL SERVER 2000/2005中除了使用DTS进行数据的导入导出,我们也可以使用Transact-SQL语句进行导入导出操作.在Transact-SQL语句中,我们主要使用OpenData ...

  6. SQL Server 与 Excel,Access 数据表的导入导出(注:参照博园.NET大观)

    我们知道在Sql Server 中 集成了数据的导入导出这么一个工具,那用Sql 脚本怎么轻松操作 Access 和 Excel 中的数据呢,接下来我们看一看: 一. SQL SERVER 和EXCE ...

  7. csv和excel php 解析_PHP 高效导入导出Excel(csv)方法之fgetcsv()和fputcsv()函数

    CSV,是Comma Separated Value(逗号分隔值)的英文缩写,通常都是纯文本文件. 一.CSV数据导入函数fgetcsv() fgetcsv() 函数从文件指针中读入一行并解析 CSV ...

  8. 三行Python代码,实现数据库和excel之间的导入导出!

    大家好,我是辰哥 之前有小伙伴私信我使用python如何将excel文件与mysql之间进行快速转换?今天我把这个方案写出来供大家参考. 数据库->Excel 使用Python代码实现数据从数据 ...

  9. python导入excel数据-Python数据处理之导入导出excel数据

    欢迎点击上方"AntDream"关注我 .Python的一大应用就是数据分析了,而数据分析中,经常碰到需要处理Excel数据的情况.这里做一个Python处理Excel数据的总结, ...

最新文章

  1. 提气!清华成立集成电路学院,专研“卡脖子”技术
  2. OC第八节 内存管理高级
  3. 113. 路径总和 (剑指 Offer 34. 二叉树中和为某一值的路径)(回溯算法)
  4. php 设计模式 控制反转,关于设计模式:控制反转究竟是什么
  5. Java 9 新特性概述
  6. 基于gulp编写的一个简单实用的前端开发环境
  7. [转]Microsoft SQL Server 自定义函数整理大全
  8. Nginx 安装配置
  9. ArcGIS行政区位图制作流程(附行政区划练习数据)
  10. 你知道怎么下载矢量图标吗——Iconfont
  11. .net core | donet core IIS 文件路径问题
  12. CQF笔记M1L2二叉树模型
  13. 【Python】爬取贝壳网深圳二手房数据
  14. 客户端开发 Windows驱动开发(1)SDK WDK DDK WDM的关系
  15. mysql id不重复随机码_MySQL 随机不重复ID,该怎么处理
  16. vmos虚拟位置_VMOS Pro 虚拟大师一款在安卓手机运行虚拟机的app
  17. 客户网站中经常用到的英文
  18. 服务器每个月维护要1000元,点评封神榜-关于服务器维护
  19. 滴水逆向win32学习笔记1
  20. 网站前端进行违禁词过滤js代码

热门文章

  1. 充电桩和换电站哪个前景更好
  2. android 5.0连接wifi,安卓5.0wifi感叹号怎么办?android 5.0wifi无法连接解决方法
  3. everpano 3D立体漫游软件
  4. 静态中国风PPT模板
  5. 时间同步服务器:时间同步的三种方式
  6. 2023年AP考试时间安排
  7. 如何在 iPhone 上恢复已删除的通话记录/通话记录
  8. WinHex v20.0 绿色单文件版
  9. PMP认证的通过率怎么样?
  10. java 获取上个月的所有日期