public ArrayList<String> daochu() throws IOException, ClassNotFoundException{
//初始一个workbook
HSSFWorkbook workbook = new HSSFWorkbook();
//创建一个sheet
HSSFSheet sheet = workbook.createSheet("stustu");
HSSFRow row = sheet.createRow((int) 0);
HSSFCellStyle style = workbook.createCellStyle();
style.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
HSSFCell cell = row.createCell((short) 0);
cell.setCellValue("组织名称");
cell.setCellStyle(style);
cell = row.createCell((short) 1);
cell.setCellValue("组织类别");
cell.setCellStyle(style);
Map<String, String> depttypeMap = sysDicService.queryDicByType("DEPTTYPE");
ArrayList<String> listo=new ArrayList<String>();
for(String k : depttypeMap.keySet()){
System.out.println(k+"----------------------**"+depttypeMap.get(k));
int x=Integer.valueOf(k);
listo.add(depttypeMap.get(k));
}
String strings[]=new String[listo.size()];
for(int i=0,j=listo.size();i<j;i++){
strings[i]=listo.get(i);
}
CellRangeAddressList regions = new CellRangeAddressList(1, 10, 4, 4);
DVConstraint constraint = DVConstraint.createExplicitListConstraint(strings);
//绑定
HSSFDataValidation dataValidation = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(dataValidation);
FileOutputStream fout = new FileOutputStream("E:/students.xlsx");
workbook.write(fout);
fout.close();
ArrayList<String> list1 = new ArrayList<String>();
list1.add("E:/students.xlsx");
return list1;
}
//初始一个workbook
HSSFWorkbook workbook = new HSSFWorkbook();
//创建一个sheet
HSSFSheet sheet = workbook.createSheet("stustu");
HSSFRow row = sheet.createRow((int) 0);
HSSFCellStyle style = workbook.createCellStyle();
style.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
HSSFCell cell = row.createCell((short) 0);
cell.setCellValue("组织名称");
cell.setCellStyle(style);
cell = row.createCell((short) 1);
cell.setCellValue("组织类别");
cell.setCellStyle(style);
Map<String, String> depttypeMap = sysDicService.queryDicByType("DEPTTYPE");
ArrayList<String> listo=new ArrayList<String>();
for(String k : depttypeMap.keySet()){
System.out.println(k+"----------------------**"+depttypeMap.get(k));
int x=Integer.valueOf(k);
listo.add(depttypeMap.get(k));
}
String strings[]=new String[listo.size()];
for(int i=0,j=listo.size();i<j;i++){
strings[i]=listo.get(i);
}
CellRangeAddressList regions = new CellRangeAddressList(1, 10, 4, 4);
DVConstraint constraint = DVConstraint.createExplicitListConstraint(strings);
//绑定
HSSFDataValidation dataValidation = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(dataValidation);
FileOutputStream fout = new FileOutputStream("E:/students.xlsx");
workbook.write(fout);
fout.close();
ArrayList<String> list1 = new ArrayList<String>();
list1.add("E:/students.xlsx");
return list1;
}