在开发中导出导入数据,我们是经常用到的,近期,公司开发中需要将指定数据导入到用户给定的EXCEL模板中,并根据要求合并单元格,在这里,我写了个简单的demo,可以概括我所用到的知识点,以供有需要的朋友借鉴。
相关DEMO下载:PoiTest
public class Test {
public static void main(String[] args) {
try{
FileInputStream fis = new FileInputStream("d:/model.xlsx");
XSSFWorkbook workBook=new XSSFWorkbook(fis);
String fileName="test_"+System.currentTimeMillis()+".xlsx";
OutputStream out=new FileOutputStream("d:/"+fileName);
XSSFCellStyle style = CellStyle.getStyle(workBook);