xls 格式的excel 转java 实体类
ReadExcel3.class
package tool.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.io.FileUtils;
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.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ReadExcel3 {
//资源绝对路径
public static StringxlsPath="F:\\文档\\实体类\\黑名单.xls";
//资源的目录
public static StringdirPath="F:\\文档\\实体类\\";
//输出路径
public static StringjavaPath="";
//字段名列
public static int attributesIndex=0;
//类型列
public static int typesIndex=2;
//注释列
public static int[]marksIndex={1,4,3};
//是否为空注释
// public static int marksEmptyIndex=3;
public static void main(String[] args)throws IOException, InvalidFormatException {
// TODO Auto-generated method stub
File file =new File(dirPath);
ArrayList files =getListFiles(file);
for(File f:files){
createJAVA( f);
}
}
public static void createJAVA(File file)throws IOException, InvalidFormatException {
String fileName = file.getName();
String className ="demo";
File file1 =null;
FileOutputStream fop =null;
List types =new ArrayList();