JgForm jgForm = (JgForm) form;
JgService js = new JgService();
String taskno1 = jgForm.getTaskno();
System.out.print("taskno=" + taskno1);
String prodcate = jgForm.getProdCate();
Long chanpinxinxiId = jgForm.getChanPinxinxi_ID();
Long entId = jgForm.getEnt_id();
String districtcode = jgForm.getDistrictCode();
String orgcode = jgForm.getOrgCode();
String insresult = jgForm.getInsResult();
String insorg = jgForm.getInsOrg();
List list1 = js.findAllDaochuJg(taskno1, prodcate, chanpinxinxiId,
entId, districtcode, orgcode, insresult, insorg);
System.out.println("list long=" + list1.size());
HSSFWorkbook workbook = new HSSFWorkbook();// 建立新HSSFWorkbook对象
HSSFSheet sheet = workbook.createSheet("结果信息");
if (list1 == null) {
list1 = new ArrayList();
}
ChouJg jg = null;
HSSFRow row01 = null;
for (int i = 0; i < list1.size(); i++) {
jg = (ChouJg) list1.get(i);
row01 = sheet.createRow((short) i);// 建立新行
HSSFCell cell1 = row01.createCell((short) 1);// 建立新cell
System.out.println("-------id----" + jg.getJgid());
cell1.setCellValue(jg.getJgid());
HSSFCell cell2 = row01.createCell((short) 2);// 建立新cell
cell2.setCellValue(jg.getTaskno());
HSSFCell cell3 = row01.createCell((short) 3);// 建立新cell
cell3.setCellValue(jg.getBrand());
}
try {
ServletOutputStream out = response.getOutputStream();
/* FileOutputStream fileOut = new FileOutputStream("workbook.xls");
workbook.write(fileOut);
fileOut.flush();
fileOut.close();
File file = new File("workbook.xls"); */
//
// ByteArrayOutputStream af = new ByteArrayOutputStream();
// af.writeTo(f);
// af.toByteArray();
//
response.setContentType("application/msexcel");
response.setHeader("Content-Disposition","attachment; filename=ddd.xls");
response.setCharacterEncoding("utf-8");
// out.write(getBytesFromFile(file));
//out.write(workbook.getBytes());
workbook.write(out);
System.out.println("sdffffffffff====");
out.flush();
out.close();
/* response.setContentType("application/msexcel");
response.setHeader("Content-Disposition",
"attachment; filename=ss.xls");
FileInputStream stream = new FileInputStream(file);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = stream.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
System.out.println("sdfhhhsdfs=");
out.flush();
out.close();*/
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
JgService js = new JgService();
String taskno1 = jgForm.getTaskno();
System.out.print("taskno=" + taskno1);
String prodcate = jgForm.getProdCate();
Long chanpinxinxiId = jgForm.getChanPinxinxi_ID();
Long entId = jgForm.getEnt_id();
String districtcode = jgForm.getDistrictCode();
String orgcode = jgForm.getOrgCode();
String insresult = jgForm.getInsResult();
String insorg = jgForm.getInsOrg();
List list1 = js.findAllDaochuJg(taskno1, prodcate, chanpinxinxiId,
entId, districtcode, orgcode, insresult, insorg);
System.out.println("list long=" + list1.size());
HSSFWorkbook workbook = new HSSFWorkbook();// 建立新HSSFWorkbook对象
HSSFSheet sheet = workbook.createSheet("结果信息");
if (list1 == null) {
list1 = new ArrayList();
}
ChouJg jg = null;
HSSFRow row01 = null;
for (int i = 0; i < list1.size(); i++) {
jg = (ChouJg) list1.get(i);
row01 = sheet.createRow((short) i);// 建立新行
HSSFCell cell1 = row01.createCell((short) 1);// 建立新cell
System.out.println("-------id----" + jg.getJgid());
cell1.setCellValue(jg.getJgid());
HSSFCell cell2 = row01.createCell((short) 2);// 建立新cell
cell2.setCellValue(jg.getTaskno());
HSSFCell cell3 = row01.createCell((short) 3);// 建立新cell
cell3.setCellValue(jg.getBrand());
}
try {
ServletOutputStream out = response.getOutputStream();
/* FileOutputStream fileOut = new FileOutputStream("workbook.xls");
workbook.write(fileOut);
fileOut.flush();
fileOut.close();
File file = new File("workbook.xls"); */
//
// ByteArrayOutputStream af = new ByteArrayOutputStream();
// af.writeTo(f);
// af.toByteArray();
//
response.setContentType("application/msexcel");
response.setHeader("Content-Disposition","attachment; filename=ddd.xls");
response.setCharacterEncoding("utf-8");
// out.write(getBytesFromFile(file));
//out.write(workbook.getBytes());
workbook.write(out);
System.out.println("sdffffffffff====");
out.flush();
out.close();
/* response.setContentType("application/msexcel");
response.setHeader("Content-Disposition",
"attachment; filename=ss.xls");
FileInputStream stream = new FileInputStream(file);
byte[] buffer = new byte[1024];
int len = 0;
while ((len = stream.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
System.out.println("sdfhhhsdfs=");
out.flush();
out.close();*/
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;