List of usage examples for org.apache.poi.ss.usermodel Picture resize
void resize();
From source file:functions.excels.Excel.java
License:Apache License
/** * Insre la carte en paramtre la page donne * @param carte// w w w . j av a2 s. c o m * @param page * @throws IOException */ public void pasteMap(Carte carte, int page) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(carte.getImage(), "png", os); byte[] bytes = os.toByteArray(); int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); CreationHelper helper = wb.getCreationHelper(); Sheet sheet = wb.getSheetAt(0); // Create the drawing patriarch. This is the top level container for all shapes. Drawing drawing = sheet.createDrawingPatriarch(); //add a picture shape ClientAnchor anchor = helper.createClientAnchor(); //set top-left corner of the picture, //subsequent call of Picture#resize() will operate relative to it anchor.setCol1(4); anchor.setRow1(LIGNES * page + 10); Picture pict = drawing.createPicture(anchor, pictureIdx); //auto-size picture relative to its top-left corner pict.resize(); }
From source file:info.informationsea.tableio.excel.ExcelImageSheetWriter.java
License:Open Source License
public void addImage(ImageType type, byte[] data) { int pictureType; switch (type) { case TYPE_JPEG: pictureType = Workbook.PICTURE_TYPE_JPEG; break;// w w w . ja v a 2s. c o m case TYPE_PNG: pictureType = Workbook.PICTURE_TYPE_PNG; break; default: throw new IllegalArgumentException("Image type should be jpeg or png"); } int pictureIndex = sheet.getWorkbook().addPicture(data, pictureType); CreationHelper creationHelper = sheet.getWorkbook().getCreationHelper(); Drawing drawing = sheet.createDrawingPatriarch(); ClientAnchor anchor = creationHelper.createClientAnchor(); anchor.setCol1(1); anchor.setRow1(nextRow); Picture picture = drawing.createPicture(anchor, pictureIndex); picture.resize(); nextRow = picture.getPreferredSize().getRow2() + 1; }
From source file:nc.noumea.mairie.appock.util.StockSpreadsheetExporter.java
License:Open Source License
private static void addImage(XSSFWorkbook workbook, XSSFSheet worksheet, File file, int rowNum) throws IOException { //add picture data to this workbook. InputStream is = new FileInputStream(file); byte[] bytes = IOUtils.toByteArray(is); int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); is.close();/* w w w . ja va 2s. c om*/ XSSFDrawing drawing = worksheet.createDrawingPatriarch(); //add a picture shape XSSFClientAnchor anchor = workbook.getCreationHelper().createClientAnchor(); anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_DONT_RESIZE); //set top-left corner of the picture, //subsequent call of Picture#resize() will operate relative to it anchor.setCol1(0); anchor.setRow1(rowNum); Picture pict = drawing.createPicture(anchor, pictureIdx); //auto-size picture relative to its top-left corner pict.resize(); //get the picture width int pictWidthPx = pict.getImageDimension().width; int pictHeightPt = pict.getImageDimension().height; //get the cell width float cellWidthPx = worksheet.getColumnWidthInPixels(0); float cellHeightPx = ConvertImageUnits.heightUnits2Pixel(worksheet.getRow(rowNum).getHeight()); //calculate the center position int centerPosPx = Math.round(cellWidthPx / 2f - (float) pictWidthPx / 2f); int centerPosPy = Math.round(cellHeightPx / 2f - (float) pictHeightPt / 2f + 10); //set the new upper left anchor position anchor.setCol1(0); //set the remaining pixels up to the center position as Dx in unit EMU anchor.setDx1(centerPosPx * Units.EMU_PER_PIXEL); anchor.setDy1(centerPosPy * Units.EMU_PER_PIXEL); //resize the pictutre to original size again //this will determine the new bottom rigth anchor position pict.resize(); }
From source file:org.nuxeo.ecm.platform.groups.audit.service.acl.excel.ExcelBuilder.java
License:Open Source License
@Override public void setPicture(int pictureIdx, int col1, int row1, boolean resize) { ClientAnchor anchor = create.createClientAnchor(); // set top-left corner of the picture, // subsequent call of Picture#resize() will operate relative to it anchor.setCol1(col1);// www. j a va 2 s .c o m anchor.setRow1(row1); Picture pict = drawing.createPicture(anchor, pictureIdx); // auto-size picture relative to its top-left corner if (resize) pict.resize(); }
From source file:tw.edu.chit.struts.action.registration.ReportPrintAction.java
/** * ???/*www . j av a 2 s .c o m*/ * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ private void printClassStudentsRegistrationCard(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); MemberManager mm = (MemberManager) getBean(IConstants.MEMBER_MANAGER_BEAN_NAME); CourseManager cm = (CourseManager) getBean(IConstants.COURSE_MANAGER_BEAN_NAME); ScoreManager sm = (ScoreManager) getBean(IConstants.SCORE_MANAGER_BEAN_NAME); ServletContext context = request.getSession().getServletContext(); String year = cm.getNowBy("School_year"); // ????? // String term = form.getString("sterm"); // ?? List<Clazz> clazzes = sm.findClassBy(new Clazz(processClassInfo(form)), getUserCredential(session).getClassInChargeAry(), false); if (!clazzes.isEmpty()) { List<Student> students = null; HSSFSheet sheet = null; String departClass = null; RegistrationCard rc = null; StdImage image = null; String studentNo = null; int sheetIndex = 0, pictureIndex = 0; byte[] bytes = null; // CreationHelper helper = null; Drawing drawing = null; // ClientAnchor anchor = null; HSSFClientAnchor anchor1 = null; Picture pict = null; DateFormat df = new SimpleDateFormat("yyyy/MM/dd"); File templateXLS = new File(context.getRealPath("/WEB-INF/reports/ClassStudentsRegistrationCard.xls")); HSSFWorkbook workbook = Toolket.getHSSFWorkbook(templateXLS); HSSFFont fontSize18 = workbook.createFont(); fontSize18.setFontHeightInPoints((short) 18); fontSize18.setFontName("Arial Unicode MS"); HSSFFont fontSize12 = workbook.createFont(); fontSize12.setFontHeightInPoints((short) 12); fontSize12.setFontName("Arial Unicode MS"); HSSFFont fontSize11 = workbook.createFont(); fontSize11.setFontHeightInPoints((short) 11); fontSize11.setFontName("Arial Unicode MS"); HSSFFont fontSize8 = workbook.createFont(); fontSize8.setFontHeightInPoints((short) 8); fontSize8.setFontName("Arial Unicode MS"); for (Clazz clazz : clazzes) { if (!Toolket.isNewStudentClass(clazz.getClassNo())) continue; departClass = clazz.getClassNo(); students = mm.findStudentsByClassNo(departClass); if (!students.isEmpty()) { sheetIndex = 0; for (Student student : students) { studentNo = student.getStudentNo(); sheet = workbook.getSheetAt(sheetIndex); workbook.setSheetName(sheetIndex++, studentNo.toUpperCase()); // Header Toolket.setCellValue(workbook, sheet, 1, 0, Toolket.getCellValue(sheet, 1, 0).replaceAll("YEAR", year), fontSize18, HSSFCellStyle.ALIGN_CENTER, false, null, null); Toolket.setCellValue(workbook, sheet, 1, 13, Toolket.getCellValue(sheet, 1, 13).replaceAll("YEAR", year), fontSize18, HSSFCellStyle.ALIGN_CENTER, false, null, null); // Columns Toolket.setCellValue(workbook, sheet, 2, 1, student.getStudentNo(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 2, 4, student.getStudentName(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 2, 8, Toolket.getClassFullName(student.getDepartClass()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 3, 1, StringUtils.isBlank(student.getStudentEname()) ? "" : student.getStudentEname(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 3, 9, student.getIdno(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 4, 1, Toolket.getSex(student.getSex()), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); // Toolket.setCellValue(workbook, sheet, 4, 3, df // .format(student.getBirthday()), fontSize11, // HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 4, 3, printNativeDate(df.format(student.getBirthday())), fontSize11, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 4, 9, StringUtils.isBlank(student.getIdent()) ? "" : Toolket.getIdentity(student.getIdent()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 9, 1, (StringUtils.isBlank(student.getPermPost()) ? "" : student.getPermPost()) + " " + (StringUtils.isBlank(student.getPermAddr()) ? "" : student.getPermAddr()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, null, null); Toolket.setCellValue(workbook, sheet, 9, 9, student.getTelephone(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 10, 9, student.getCellPhone(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 11, 2, student.getParentName(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 12, 2, student.getCurrPost() + " " + student.getCurrAddr(), fontSize8, HSSFCellStyle.ALIGN_LEFT, true, null, null); image = new StdImage(); image.setStudentNo(student.getStudentNo()); image = mm.findStdImageBy(image); if (image != null) { bytes = image.getImage().getBytes(1l, (int) image.getImage().length()); // Image im = // java.awt.Toolkit.getDefaultToolkit().getImage(filename); try { pictureIndex = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG); } catch (Exception e) { try { pictureIndex = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG); } catch (Exception e1) { pictureIndex = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PICT); } } // helper = workbook.getCreationHelper(); drawing = sheet.createDrawingPatriarch(); // anchor = helper.createClientAnchor(); anchor1 = new HSSFClientAnchor(0, 0, 400, 100, (short) 13, 19, (short) 17, 29); anchor1.setAnchorType(0); // anchor.setCol1(13); // anchor.setRow1(19); pict = drawing.createPicture(anchor1, pictureIndex); try { pict.resize(); // 154611 // pict.resize(0.5); } catch (Exception e) { e.printStackTrace(); log.error(e.getMessage(), e); } } if (student.getRegistrationCard() != null) { rc = student.getRegistrationCard(); Toolket.setCellValue(workbook, sheet, 2, 8, Toolket.getCellValue(sheet, 2, 8) + " " + (rc.getDiviName() == null ? "" : rc.getDiviName().trim()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 3, 5, StringUtils.isBlank(rc.getBirthCountry()) ? "" : rc.getBirthCountry().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 4, 5, StringUtils.isBlank(rc.getBirthPlace()) ? "" : rc.getBirthPlace().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 5, 2, StringUtils.isBlank(rc.getAborigine()) ? "" : rc.getAborigine().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 5, 5, StringUtils.isBlank(rc.getForeignPlace()) ? "" : rc.getForeignPlace().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 5, 9, rc.getArmyIn() == null ? "?" : "?" + df.format(rc.getArmyIn()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 6, 9, rc.getArmyOut() == null ? "?" : "?" + df.format(rc.getArmyOut()), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 7, 3, StringUtils.isBlank(rc.getBeforeSchool()) ? "" : rc.getBeforeSchool().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 7, 9, StringUtils.isBlank(rc.getGradeYear()) ? "" : rc.getGradeYear(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 7, 11, rc.getGradeType() == null ? "" : rc.getGradeType().toString(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 8, 3, StringUtils.isBlank(rc.getBeforeDept()) ? "" : rc.getBeforeDept().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 11, 5, StringUtils.isBlank(rc.getParentAge()) ? "" : rc.getParentAge().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 11, 7, StringUtils.isBlank(rc.getParentCareer()) ? "" : rc.getParentCareer().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 11, 11, StringUtils.isBlank(rc.getParentRelationship()) ? "" : rc.getParentRelationship().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 12, 10, StringUtils.isBlank(rc.getEmergentPhone()) ? "" : rc.getEmergentPhone().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 13, 10, StringUtils.isBlank(rc.getEmergentCell()) ? "" : rc.getEmergentCell().trim(), fontSize12, HSSFCellStyle.ALIGN_LEFT, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 1, StringUtils.isBlank(rc.getMemberTitle1()) ? "" : rc.getMemberTitle1().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 2, StringUtils.isBlank(rc.getMemberName1()) ? "" : rc.getMemberName1().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 4, StringUtils.isBlank(rc.getMemberAge1()) ? "" : rc.getMemberAge1().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 5, StringUtils.isBlank(rc.getMemberCareer1()) ? "" : rc.getMemberCareer1().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 7, StringUtils.isBlank(rc.getMemberTitle2()) ? "" : rc.getMemberTitle2().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 8, StringUtils.isBlank(rc.getMemberName2()) ? "" : rc.getMemberName2().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 10, StringUtils.isBlank(rc.getMemberAge2()) ? "" : rc.getMemberAge2().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 15, 11, StringUtils.isBlank(rc.getMemberCareer2()) ? "" : rc.getMemberCareer2().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 1, StringUtils.isBlank(rc.getMemberTitle3()) ? "" : rc.getMemberTitle3().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 2, StringUtils.isBlank(rc.getMemberName3()) ? "" : rc.getMemberName3().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 4, StringUtils.isBlank(rc.getMemberAge3()) ? "" : rc.getMemberAge3().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 5, StringUtils.isBlank(rc.getMemberCareer3()) ? "" : rc.getMemberCareer3().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 7, StringUtils.isBlank(rc.getMemberTitle4()) ? "" : rc.getMemberTitle4().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 8, StringUtils.isBlank(rc.getMemberName4()) ? "" : rc.getMemberName4().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 10, StringUtils.isBlank(rc.getMemberAge4()) ? "" : rc.getMemberAge4().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); Toolket.setCellValue(workbook, sheet, 16, 11, StringUtils.isBlank(rc.getMemberCareer4()) ? "" : rc.getMemberCareer4().trim(), fontSize12, HSSFCellStyle.ALIGN_CENTER, true, false, null, null); } } } } File tempDir = new File( context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, "ClassStudentRegistrationCard.xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); } else { Map<String, String> param = new HashMap<String, String>(); File image = new File(context.getRealPath("/pages/images/2002chitS.jpg")); param.put("IMAGE", image.getAbsolutePath()); byte[] bytes = JasperRunManager.runReportToPdf(JasperReportUtils.getNoResultReport(context), param, new JREmptyDataSource()); JasperReportUtils.printPdfToFrontEnd(response, bytes); } }
From source file:Valuacion.Exporta.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: if(t_orden.getText().compareTo("")!=0) {/*from w w w. j ava 2 s. c o m*/ FileNameExtensionFilter filtroImagen=new FileNameExtensionFilter("XLS","xls"); aviso.setFileFilter(filtroImagen); int r=aviso.showSaveDialog(null); if(r==aviso.APPROVE_OPTION) { boolean respuesta=true; File a=aviso.getSelectedFile(); File archivoXLS=null; if(a.exists()==true) { int i=JOptionPane.showConfirmDialog(null, "Deseas remplazar el archivo?", "confirmacin", JOptionPane.YES_NO_OPTION); if(i!=0) { respuesta=false; } else archivoXLS=a; } else { if(a.getName().indexOf(".xls")==-1) a= new File(a.getAbsoluteFile()+".xls"); archivoXLS=a; } if(respuesta==true) { Session session = HibernateUtil.getSessionFactory().openSession(); try { orden_act = (Orden)session.get(Orden.class, orden_act.getIdOrden()); //if(orden_act.getPedidos().isEmpty()==true) //{ //File archivoXLS = new File(t_orden.getText()+".xls"); if(archivoXLS.exists()) archivoXLS.delete(); Biff8EncryptionKey.setCurrentUserPassword("04650077"); archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja1 = libro.createSheet("especialidad"); Sheet hoja2 = libro.createSheet("catalogo"); Sheet hoja3 = libro.createSheet("marca"); Sheet hoja4 = libro.createSheet("tipo"); Sheet hoja5 = libro.createSheet("ejemplar"); Sheet hoja6 = libro.createSheet("orden"); Sheet hoja7 = libro.createSheet("partida"); Sheet hoja8 = libro.createSheet("compania"); Sheet hoja9 = libro.createSheet("imagen"); //***************************imagen******************************* Foto[] fotos = (Foto[]) orden_act.getFotos().toArray(new Foto[0]); for(int k=0;k<fotos.length-1;k++) { for(int f=0;f<(fotos.length-1)-k;f++) { if (fotos[f].getFecha().after(fotos[f+1].getFecha())==true) { Foto aux; aux=fotos[f]; fotos[f]=fotos[f+1]; fotos[f+1]=aux; } } } if(fotos.length>0) { try { InputStream is = new FileInputStream(ruta+"ordenes/"+orden_act.getIdOrden()+"/miniatura/"+fotos[0].getDescripcion()); byte[] bytes = IOUtils.toByteArray(is); int pictureIdx = libro.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG); is.close(); CreationHelper helper = libro.getCreationHelper(); Drawing drawing = hoja9.createDrawingPatriarch(); ClientAnchor anchor = helper.createClientAnchor(); anchor.setCol1(3); anchor.setRow1(2); Picture pict = drawing.createPicture(anchor, pictureIdx); pict.resize(); }catch(Exception e){e.printStackTrace();} } //************************especialidad***************************** Especialidad[] especialidad = (Especialidad[])session.createCriteria(Especialidad.class).list().toArray(new Especialidad[0]); Row h1r0=hoja1.createRow(0); h1r0.createCell(0).setCellValue("Partida"); h1r0.createCell(1).setCellValue("sub"); h1r0.createCell(2).setCellValue("registro"); if(especialidad.length>0) { for(int i=0; i<especialidad.length; i++) { Row fh1 = hoja1.createRow(i+1); fh1.createCell(0).setCellValue(especialidad[i].getIdGrupoMecanico()); if(especialidad[i].getDescripcion()!=null) fh1.createCell(1).setCellValue(especialidad[i].getDescripcion()); else fh1.createCell(1).setCellValue(""); fh1.createCell(2).setCellValue("o"); } } //************************catalogo***************************** Catalogo[] catalogo = (Catalogo[])session.createCriteria(Catalogo.class).list().toArray(new Catalogo[0]); Row h2r0=hoja2.createRow(0); h2r0.createCell(0).setCellValue("id_catalogo"); h2r0.createCell(1).setCellValue("nombre"); h2r0.createCell(2).setCellValue("id_especialidad"); h2r0.createCell(3).setCellValue("registro"); if(catalogo.length>0) { for(int i=0; i<catalogo.length; i++) { Row fh2 = hoja2.createRow(i+1); fh2.createCell(0).setCellValue(catalogo[i].getIdCatalogo()); if(catalogo[i].getNombre()!=null) fh2.createCell(1).setCellValue(catalogo[i].getNombre()); else fh2.createCell(1).setCellValue(""); fh2.createCell(2).setCellValue(catalogo[i].getEspecialidad().getIdGrupoMecanico()); fh2.createCell(3).setCellValue("o"); } } //************************marca***************************** Marca[] marca = (Marca[])session.createCriteria(Marca.class).list().toArray(new Marca[0]); Row h3r0=hoja3.createRow(0); h3r0.createCell(0).setCellValue("id_marca"); h3r0.createCell(1).setCellValue("nombre_marca"); h3r0.createCell(2).setCellValue("registro"); if(marca.length>0) { for(int i=0; i<marca.length; i++) { Row fh3 = hoja3.createRow(i+1); fh3.createCell(0).setCellValue(marca[i].getIdMarca()); fh3.createCell(1).setCellValue(marca[i].getMarcaNombre()); fh3.createCell(2).setCellValue("o"); } } //************************tipo***************************** Tipo[] tipo = (Tipo[])session.createCriteria(Tipo.class).list().toArray(new Tipo[0]); Row h4r0=hoja4.createRow(0); h4r0.createCell(0).setCellValue("tipo_nombre"); h4r0.createCell(1).setCellValue("e_pesado"); h4r0.createCell(2).setCellValue("registro"); if(tipo.length>0) { for(int i=0; i<tipo.length; i++) { Row fh4 = hoja4.createRow(i+1); fh4.createCell(0).setCellValue(tipo[i].getTipoNombre()); fh4.createCell(1).setCellValue(tipo[i].getEPesado()); fh4.createCell(2).setCellValue("o"); } } //************************ejemplar***************************** Ejemplar[] ejemplar = (Ejemplar[])session.createCriteria(Ejemplar.class).list().toArray(new Ejemplar[0]); Row h5r0=hoja5.createRow(0); h5r0.createCell(0).setCellValue("id_parte"); h5r0.createCell(1).setCellValue("id_marca"); h5r0.createCell(2).setCellValue("tipo_nombre"); h5r0.createCell(3).setCellValue("modelo"); h5r0.createCell(4).setCellValue("id_catalogo"); h5r0.createCell(5).setCellValue("comentario"); h5r0.createCell(6).setCellValue("registro"); if(ejemplar.length>0) { for(int i=0; i<ejemplar.length; i++) { Row fh5 = hoja5.createRow(i+1); fh5.createCell(0).setCellValue(ejemplar[i].getIdParte()); if(ejemplar[i].getMarca()!=null) fh5.createCell(1).setCellValue(ejemplar[i].getMarca().getIdMarca()); else fh5.createCell(1).setCellValue(""); if(ejemplar[i].getTipo()!=null) fh5.createCell(2).setCellValue(ejemplar[i].getTipo().getTipoNombre()); else fh5.createCell(2).setCellValue(""); if(ejemplar[i].getModelo()!=null) fh5.createCell(3).setCellValue(ejemplar[i].getModelo()); else fh5.createCell(3).setCellValue(""); if(ejemplar[i].getCatalogo()!=null) fh5.createCell(4).setCellValue(ejemplar[i].getCatalogo()); else fh5.createCell(4).setCellValue(""); if(ejemplar[i].getComentario()!=null) fh5.createCell(5).setCellValue(ejemplar[i].getComentario()); else fh5.createCell(5).setCellValue(""); fh5.createCell(6).setCellValue("o"); } } //************************orden***************************** orden_act = (Orden)session.get(Orden.class, orden_act.getIdOrden()); Row h6r0=hoja6.createRow(0); h6r0.createCell(0).setCellValue("id_orden"); h6r0.createCell(1).setCellValue("aseguradora"); h6r0.createCell(2).setCellValue("poliza"); h6r0.createCell(3).setCellValue("siniestro"); h6r0.createCell(4).setCellValue("inciso"); h6r0.createCell(5).setCellValue("reporte"); h6r0.createCell(6).setCellValue("fecha"); h6r0.createCell(7).setCellValue("nombre"); h6r0.createCell(8).setCellValue("tipo_cliente"); h6r0.createCell(9).setCellValue("id_marca"); h6r0.createCell(10).setCellValue("tipo"); h6r0.createCell(11).setCellValue("anio"); h6r0.createCell(12).setCellValue("registro"); Row fh6 = hoja6.createRow(1); fh6.createCell(0).setCellValue(orden_act.getIdOrden()); fh6.createCell(1).setCellValue(orden_act.getCompania().getIdCompania()); if(orden_act.getPoliza()!=null) fh6.createCell(2).setCellValue(orden_act.getPoliza()); else fh6.createCell(2).setCellValue(""); if(orden_act.getSiniestro()!=null) fh6.createCell(3).setCellValue(orden_act.getSiniestro()); else fh6.createCell(3).setCellValue(""); if(orden_act.getInciso()!=null) fh6.createCell(4).setCellValue(orden_act.getInciso()); else fh6.createCell(4).setCellValue(""); if(orden_act.getNoReporte()!=null) fh6.createCell(5).setCellValue(orden_act.getNoReporte()); else fh6.createCell(5).setCellValue(""); fh6.createCell(6).setCellValue(orden_act.getFecha()); fh6.createCell(7).setCellValue(orden_act.getClientes().getNombre()); fh6.createCell(8).setCellValue(orden_act.getTipoCliente()); fh6.createCell(9).setCellValue(orden_act.getMarca().getIdMarca()); fh6.createCell(10).setCellValue(orden_act.getTipo().getTipoNombre()); fh6.createCell(11).setCellValue(orden_act.getModelo()); fh6.createCell(12).setCellValue("o"); Compania com=orden_act.getCompania(); Row h8r0=hoja8.createRow(0); h8r0.createCell(0).setCellValue("id_compania"); h8r0.createCell(1).setCellValue("nombre"); h8r0.createCell(2).setCellValue("importe_hota"); h8r0.createCell(3).setCellValue("importe_max"); h8r0.createCell(4).setCellValue("registro"); Row fh8 = hoja8.createRow(1); fh8.createCell(0).setCellValue(com.getIdCompania()); fh8.createCell(1).setCellValue(com.getNombre()); fh8.createCell(2).setCellValue(com.getImporteHora()); fh8.createCell(3).setCellValue(com.getImporteMax()); fh8.createCell(4).setCellValue("o"); //************************partida***************************** Partida[] cuentas = (Partida[])session.createCriteria(Partida.class).add(Restrictions.eq("ordenByIdOrden.idOrden", orden_act.getIdOrden())).addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list().toArray(new Partida[0]); Partida[] enlazadas = (Partida[])session.createCriteria(Partida.class).add(Restrictions.eq("ordenByEnlazada.idOrden", orden_act.getIdOrden())).addOrder(Order.asc("idEvaluacion")).addOrder(Order.asc("subPartida")).list().toArray(new Partida[0]); Row h7r0=hoja7.createRow(0); h7r0.createCell(0).setCellValue("id_partida"); h7r0.createCell(1).setCellValue("id_evaluacion"); h7r0.createCell(2).setCellValue("sub_partida"); h7r0.createCell(3).setCellValue("esp_hoj"); h7r0.createCell(4).setCellValue("esp_mec"); h7r0.createCell(5).setCellValue("esp_sus"); h7r0.createCell(6).setCellValue("esp_ele"); h7r0.createCell(7).setCellValue("dm"); h7r0.createCell(8).setCellValue("cam"); h7r0.createCell(9).setCellValue("rep_min"); h7r0.createCell(10).setCellValue("rep_med"); h7r0.createCell(11).setCellValue("rep_max"); h7r0.createCell(12).setCellValue("pint"); h7r0.createCell(13).setCellValue("cant"); h7r0.createCell(14).setCellValue("med"); h7r0.createCell(15).setCellValue("id_catalogo"); h7r0.createCell(16).setCellValue("id_parte"); h7r0.createCell(17).setCellValue("incluida"); h7r0.createCell(18).setCellValue("ori"); h7r0.createCell(19).setCellValue("nal"); h7r0.createCell(20).setCellValue("desm"); h7r0.createCell(21).setCellValue("pd"); h7r0.createCell(22).setCellValue("tot"); h7r0.createCell(23).setCellValue("int_desm"); h7r0.createCell(24).setCellValue("int_camb"); h7r0.createCell(25).setCellValue("int_rep_min"); h7r0.createCell(26).setCellValue("int_rep_med"); h7r0.createCell(27).setCellValue("int_rep_max"); h7r0.createCell(28).setCellValue("int_pin_min"); h7r0.createCell(29).setCellValue("int_pin_med"); h7r0.createCell(30).setCellValue("int_pin_max"); h7r0.createCell(31).setCellValue("instruccion"); h7r0.createCell(32).setCellValue("tipo"); h7r0.createCell(33).setCellValue("enlazada"); h7r0.createCell(34).setCellValue("autorizado_valuacion"); h7r0.createCell(35).setCellValue("c_u"); h7r0.createCell(36).setCellValue("porcentaje"); h7r0.createCell(37).setCellValue("precio_cia"); h7r0.createCell(38).setCellValue("cant_aut"); h7r0.createCell(39).setCellValue("precio_aut"); h7r0.createCell(40).setCellValue("autorizado"); h7r0.createCell(41).setCellValue("horas"); h7r0.createCell(42).setCellValue("ref_coti"); h7r0.createCell(43).setCellValue("ref_com"); h7r0.createCell(44).setCellValue("so"); h7r0.createCell(45).setCellValue("pedido"); h7r0.createCell(46).setCellValue("entrega"); h7r0.createCell(47).setCellValue("id_orden"); h7r0.createCell(48).setCellValue("pcp"); h7r0.createCell(49).setCellValue("registro"); if(cuentas.length>0) { for(int i=0; i<cuentas.length; i++) { Row fh7 = hoja7.createRow(i+1); fh7.createCell(0).setCellValue(cuentas[i].getIdPartida()); fh7.createCell(1).setCellValue(cuentas[i].getIdEvaluacion()); fh7.createCell(2).setCellValue(cuentas[i].getSubPartida()); fh7.createCell(3).setCellValue(cuentas[i].isEspHoj()); fh7.createCell(4).setCellValue(cuentas[i].isEspMec()); fh7.createCell(5).setCellValue(cuentas[i].isEspSus()); fh7.createCell(6).setCellValue(cuentas[i].isEspEle()); fh7.createCell(7).setCellValue(cuentas[i].getDm()); fh7.createCell(8).setCellValue(cuentas[i].getCam()); fh7.createCell(9).setCellValue(cuentas[i].getRepMin()); fh7.createCell(10).setCellValue(cuentas[i].getRepMed()); fh7.createCell(11).setCellValue(cuentas[i].getRepMax()); fh7.createCell(12).setCellValue(cuentas[i].getPint()); fh7.createCell(13).setCellValue(cuentas[i].getCant()); fh7.createCell(14).setCellValue(cuentas[i].getMed()); fh7.createCell(15).setCellValue(cuentas[i].getCatalogo().getIdCatalogo()); if(cuentas[i].getEjemplar()!=null) fh7.createCell(16).setCellValue(cuentas[i].getEjemplar().getIdParte()); else fh7.createCell(16).setCellValue(""); fh7.createCell(17).setCellValue(cuentas[i].isIncluida()); fh7.createCell(18).setCellValue(cuentas[i].isOri()); fh7.createCell(19).setCellValue(cuentas[i].isNal()); fh7.createCell(20).setCellValue(cuentas[i].isDesm()); fh7.createCell(21).setCellValue(cuentas[i].isPd()); if(cuentas[i].getProveedor()!=null) fh7.createCell(22).setCellValue(cuentas[i].getProveedor().getIdProveedor()); else fh7.createCell(22).setCellValue(""); fh7.createCell(23).setCellValue(cuentas[i].getIntDesm()); fh7.createCell(24).setCellValue(cuentas[i].getIntCamb()); fh7.createCell(25).setCellValue(cuentas[i].getIntRepMin()); fh7.createCell(26).setCellValue(cuentas[i].getIntRepMed()); fh7.createCell(27).setCellValue(cuentas[i].getIntRepMax()); fh7.createCell(28).setCellValue(cuentas[i].getIntPinMin()); fh7.createCell(29).setCellValue(cuentas[i].getIntPinMed()); fh7.createCell(30).setCellValue(cuentas[i].getIntPinMax()); if(cuentas[i].getInstruccion()!=null) fh7.createCell(31).setCellValue(cuentas[i].getInstruccion()); else fh7.createCell(31).setCellValue(""); fh7.createCell(32).setCellValue(cuentas[i].getTipo()); if(cuentas[i].getOrdenByEnlazada()!=null) fh7.createCell(33).setCellValue(cuentas[i].getOrdenByEnlazada().getIdOrden()); else fh7.createCell(33).setCellValue(""); fh7.createCell(34).setCellValue(cuentas[i].isAutorizadoValuacion()); fh7.createCell(35).setCellValue(cuentas[i].getCU()); fh7.createCell(36).setCellValue(cuentas[i].getPorcentaje()); fh7.createCell(37).setCellValue(cuentas[i].getPrecioCiaSegurosCU()); fh7.createCell(38).setCellValue(cuentas[i].getCantidadAut()); fh7.createCell(39).setCellValue(cuentas[i].getPrecioAutCU()); fh7.createCell(40).setCellValue(cuentas[i].isAutorizado()); fh7.createCell(41).setCellValue(cuentas[i].getHoras()); fh7.createCell(42).setCellValue(cuentas[i].isRefCoti()); fh7.createCell(43).setCellValue(cuentas[i].isRefComp()); fh7.createCell(44).setCellValue(cuentas[i].isSo()); if(cuentas[i].getPedido()!=null) { fh7.createCell(45).setCellValue(cuentas[i].getPedido().getIdPedido()); if(cuentas[i].getPlazo()!=null) fh7.createCell(46).setCellValue(cuentas[i].getPlazo()); else fh7.createCell(46).setCellValue(""); } else { fh7.createCell(45).setCellValue(""); fh7.createCell(46).setCellValue(""); } fh7.createCell(47).setCellValue(cuentas[i].getOrdenByIdOrden().getIdOrden()); fh7.createCell(48).setCellValue(cuentas[i].getPcp()); fh7.createCell(49).setCellValue("o"); } } libro.write(archivo); Biff8EncryptionKey.setCurrentUserPassword(null); archivo.close(); JOptionPane.showMessageDialog(null, "Archivo guardado!"); /*} else { if(session.isOpen()) session.close(); JOptionPane.showMessageDialog(null, "La orden ya contiene partidas!"); }*/ } catch (Exception he) { he.printStackTrace(); session.getTransaction().rollback(); } if(session!=null) if(session.isOpen()) session.close(); } } } else JOptionPane.showMessageDialog(this, "Debes seleccionar una orden de taller primero"); }