有时需要将excel文件的数据导入到数据库中,如何能快速而简单的将excel文件导入对不会的攻城狮们尤为重要,下面就在java项目中实现了该功能
`package com.liuyegongzhi;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
/**
* 通过poi读取excel文件
*/
public class PoiExcel {
/**
*
* @param args
*/
public static void main(String[] args){
new PoiExcel().readExcleFile();
}
/**
*
* @return
*/
public String readExcleFile() {
//创建时间格式化对象
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
//创建文件对象
File file = new File(“D:\素材文件夹\工作簿1.xlsx”);
try {
//创建文件输入流
FileInputStream in = n