excel模板生成sql server建表语句

因为需要进行大量的表创建所以才有此方法,需要的请copy

package com.spf.sp.util;

import com.spf.eap.util.common.Toolkit;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ExcelToSqlUtil {

    /**
     *
     * @param filePath
     * @param storePath
     * @return
     * @throws Exception
     */
    public static List readExcel(String filePath,String storePath) throws Exception{
        File file=new File(filePath);
        if (!file.exists()) {
            return null;
        }

        /**
         * Get the suffix of the file
         */
        String suffix= filePath.substring(filePath.lastIndexOf("."));

        /**
         * if suffix cannot equals .xls && .xlsx ,return null
         */
        if(!".xls".equals(suffix) && !".xlsx".equals(suffix)){
            return null;
        }

        //返回值列
        List reaultList=new ArrayList();
        if(".xls".equals(suffix)){
            reaultList=readExcel2007(filePath,storePath);
        }else if(".xlsx".equals(suffix)){
            reaultList=readExcel2007(filePath,storePath);
        }
        return reaultList;
    }

    /**
     *
     * @param filePath
     * @param storePath
     * 

你可能感兴趣的:(java)