展开全部

你这问题太大了

HSSFWorkbook 是导出excel的工具,可是实现导出excel控制条数

//开始打印e68a84e8a2ad62616964757a686964616f31333332633566

HSSFWorkbook wb = new HSSFWorkbook();

HSSFSheet sheet=wb.createSheet("sheet1");

HSSFRow row = sheet.createRow(0);

//设置第一行标题

HSSFCell cell;

JobColumn jobColumn = null;

int colsAddSize = NewmasterstudentAction.COLS4EXPORT_CODE.length;

for(int i=0 ; i

cell = row.createCell((short)i);

cell.setCellValue(NewmasterstudentAction.COLS4EXPORT_CODE[i]+"("+NewmasterstudentAction.COLS4EXPORT_NAME[i]+")");

}

for(int i=0;i

UserJobColumn userJob = jobList.get(i);

jobColumn = userJob.getJobColumn();

cell = row.createCell((short)(i+colsAddSize));

cell.setCellValue(jobColumn.getColumnCode()+"("+jobColumn.getColumnName()+")"); //字段代码

}

//打印记录

Set>> entrySet = des.entrySet();

Iterator>> it = entrySet.iterator();

int index = 1;

while(it.hasNext()){

Entry> en = it.next();

row = sheet.createRow(index++);

String xh = en.getKey();

//打印学生信息

cell = row.createCell((short)0);

cell.setCellValue(xh);

NewMasterStudent stu = studentMap.get(xh);

if(stu != null){

cell = row.createCell((short)1);

cell.setCellValue(stu.getYbd() ? "是" : "否");

cell = row.createCell((short)2);

cell.setCellValue(stu.getRemark() == null ? "" : stu.getRemark());

}

//打印记录

List records = en.getValue();

for(int i=0 ; i

cell = row.createCell((short)(i+colsAddSize));

UserJobColumn g = jobList.get(i);

JobRecord record = null;

if(i < records.size()){

record = records.get(i);

if(!g.getJobColumn().getId().equals(record.getJobColumn().getId())){

record = new JobRecord();

record.setJobColumn(g.getJobColumn());

records.add(i, record);

}

}else{

record = new JobRecord();

record.setJobColumn(g.getJobColumn());

records.add(i, record);

}

if(Constant.NS_JOBCOLUMN_TYPE_INPUT.equals(record.getJobColumn().getColumnType())){

cell.setCellValue(record.getEditLr());

}else if(Constant.NS_JOBCOLUMN_TYPE_SELECT.equals(record.getJobColumn().getColumnType())){

cell.setCellValue(record.isEditState() ? "是":"否");

}else if(Constant.NS_JOBCOLUMN_TYPE_OPTION.equals(record.getJobColumn().getColumnType())){

SyGeneralCode select = record.getSelectedValue();

if(select != null){

cell.setCellValue(select.getCode()+" | "+select.getCnName());

}

}

}

}

ZipEntry 可以实现导出zip文件

if (files[i].exists() && !files[i].isDirectory()) {

String zjhmImg = files[i].getName();

if (zjhmMap.get(zjhmImg) != null) {

num++;

FileInputStream fi = new FileInputStream(files[i]);

origin = new BufferedInputStream(fi, BUFFER);

ZipEntry entry = new ZipEntry(files[i].getName());

out.putNextEntry(entry);

int count;

while ((count = origin.read(data, 0, BUFFER)) != -1) {

out.write(data, 0, count);

}

out.setEncoding("GBK");

origin.close();

2Q==

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐