List of usage examples for org.apache.poi.hssf.record.crypto Biff8EncryptionKey setCurrentUserPassword
public static void setCurrentUserPassword(String password)
From source file:br.com.tiagods.model.Arquivo.java
public Workbook validarWorkbook(Workbook workbook, File file, String ext, InputStream inputStream) { switch (ext) { case "xls": try {//from w w w . j av a 2 s . c om if (file.getName().equals("Cadastro.xls")) {//formula para abrir arquivo com senha Biff8EncryptionKey.setCurrentUserPassword("PLKCONTRATOS"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file, true); return workbook = new HSSFWorkbook(fs.getRoot(), true); } else { POIFSFileSystem fileSystem = new POIFSFileSystem(inputStream); return workbook = new HSSFWorkbook(fileSystem); } } catch (IOException e) { JOptionPane.showMessageDialog(null, e); return null; } case "xlsx": try { return workbook = new XSSFWorkbook(inputStream); } catch (IOException e) { JOptionPane.showMessageDialog(null, e); return null; } default: JOptionPane.showMessageDialog(null, "Formato de arquivo no permitido!"); return null; } }
From source file:com.jkoolcloud.tnt4j.streams.inputs.ExcelSXSSFRowStream.java
License:Apache License
/** * Reads HSSF (XLS) format excel file using Apache POI streaming SXSSF API. * * @param xlsFile/*from ww w. java2 s . c o m*/ * excel HSSF format file to read * * @throws IOException * if excel file or workbook can't be read */ protected void readXLS(File xlsFile) throws IOException { NPOIFSFileSystem fs = null; InputStream dis = null; boolean passwordSet = false; try { fs = new NPOIFSFileSystem(xlsFile, true); DirectoryNode root = fs.getRoot(); if (root.hasEntry("EncryptedPackage")) { // NON-NLS dis = DocumentFactoryHelper.getDecryptedStream(fs, wbPass); } else { if (wbPass != null) { Biff8EncryptionKey.setCurrentUserPassword(wbPass); passwordSet = true; } dis = fs.createDocumentInputStream("Workbook"); // NON-NLS } HSSFRequest req = new HSSFRequest(); XLSEventListener listener = new XLSEventListener(this); FormatTrackingHSSFListener formatsListener = new FormatTrackingHSSFListener(listener, Locale.getDefault()); listener.setFormatListener(formatsListener); req.addListenerForAllRecords(formatsListener); HSSFEventFactory factory = new HSSFEventFactory(); factory.processEvents(req, dis); } finally { if (passwordSet) { Biff8EncryptionKey.setCurrentUserPassword((String) null); } Utils.close(fs); Utils.close(dis); } }
From source file:com.kplot.web.data.WorkbookFactory.java
License:Apache License
/** * Creates a Workbook from the given NPOIFSFileSystem, which may * be password protected/*from w ww. j av a 2 s. c om*/ * * @param fs The {@link NPOIFSFileSystem} to read the document from * @param password The password that should be used or null if no password is necessary. * * @return The created Workbook * * @throws IOException if an error occurs while reading the data * @throws InvalidFormatException if the contents of the file cannot be parsed into a {@link Workbook} */ private static Workbook create(NPOIFSFileSystem fs, String password) throws IOException, InvalidFormatException { DirectoryNode root = fs.getRoot(); // Encrypted OOXML files go inside OLE2 containers, is this one? if (root.hasEntry(Decryptor.DEFAULT_POIFS_ENTRY)) { EncryptionInfo info = new EncryptionInfo(fs); Decryptor d = Decryptor.getInstance(info); boolean passwordCorrect = false; InputStream stream = null; try { if (password != null && d.verifyPassword(password)) { passwordCorrect = true; } if (!passwordCorrect && d.verifyPassword(Decryptor.DEFAULT_PASSWORD)) { passwordCorrect = true; } if (passwordCorrect) { stream = d.getDataStream(root); } } catch (GeneralSecurityException e) { throw new IOException(e); } if (!passwordCorrect) { if (password != null) throw new EncryptedDocumentException("Password incorrect"); else throw new EncryptedDocumentException( "The supplied spreadsheet is protected, but no password was supplied"); } OPCPackage pkg = OPCPackage.open(stream); return create(pkg); } // If we get here, it isn't an encrypted XLSX file // So, treat it as a regular HSSF XLS one if (password != null) { Biff8EncryptionKey.setCurrentUserPassword(password); } try { return new HSSFWorkbook(root, true); } finally { Biff8EncryptionKey.setCurrentUserPassword(null); } }
From source file:Contabilidad.AXA.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: FileNameExtensionFilter filtroImagen = new FileNameExtensionFilter("XLS", "xls"); aviso.setFileFilter(filtroImagen);/*from w w w .jav a 2 s .c om*/ int r = aviso.showSaveDialog(null); if (r == aviso.APPROVE_OPTION) { File a = aviso.getSelectedFile(); File archivoXLS = null; if (a.getName().indexOf(".xls") == -1) a = new File(a.getAbsoluteFile() + ".xls"); archivoXLS = a; try { if (archivoXLS.exists()) archivoXLS.delete(); archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("datos"); Row h1r0 = hoja.createRow(0); h1r0.createCell(0).setCellValue("Cant"); h1r0.createCell(1).setCellValue("Med"); h1r0.createCell(2).setCellValue("Descripcion"); h1r0.createCell(3).setCellValue("c/u"); h1r0.createCell(4).setCellValue("Descuento"); for (int x = 0; x < t_datos.getRowCount(); x++) { Row h1 = hoja.createRow(x + 1); h1.createCell(0).setCellValue((double) t_datos.getValueAt(x, 1)); h1.createCell(1).setCellValue((String) t_datos.getValueAt(x, 2)); h1.createCell(2).setCellValue((String) t_datos.getValueAt(x, 3)); h1.createCell(3).setCellValue((double) t_datos.getValueAt(x, 4)); h1.createCell(4).setCellValue((double) t_datos.getValueAt(x, 5)); } libro.write(archivo); Biff8EncryptionKey.setCurrentUserPassword(null); archivo.close(); JOptionPane.showMessageDialog(null, "Archivo guardado!"); } catch (Exception e) { e.printStackTrace(); } ; } }
From source file:de.jlo.talendcomp.excel.SpreadsheetFile.java
License:Apache License
public void initializeWorkbook() throws Exception { if (inputFile != null) { // open existing files if (currentType == SpreadsheetTyp.XLS) { if (readPassword != null) { try { // switch on decryption Biff8EncryptionKey.setCurrentUserPassword(readPassword); FileInputStream fin = new FileInputStream(inputFile); workbook = new HSSFWorkbook(fin); fin.close();//from w w w. j av a 2 s .c o m } finally { // switch off Biff8EncryptionKey.setCurrentUserPassword(null); readPassword = null; } } else { FileInputStream fin = new FileInputStream(inputFile); workbook = new HSSFWorkbook(fin); fin.close(); } } else if (currentType == SpreadsheetTyp.XLSX) { if (createStreamingXMLWorkbook) { FileInputStream fin = new FileInputStream(inputFile); try { ZipSecureFile.setMinInflateRatio(0); workbook = new SXSSFWorkbook(new XSSFWorkbook(fin), rowAccessWindow); } finally { if (fin != null) { try { fin.close(); } catch (IOException ioe) { // ignore } } } } else { if (readPassword != null) { FileInputStream fin = new FileInputStream(inputFile); POIFSFileSystem filesystem = new POIFSFileSystem(fin); EncryptionInfo info = new EncryptionInfo(filesystem); Decryptor d = Decryptor.getInstance(info); InputStream dataStream = null; try { if (!d.verifyPassword(readPassword)) { throw new Exception( "Unable to process: document is encrypted and given password does not match!"); } // decrypt dataStream = d.getDataStream(filesystem); // use open input stream workbook = new XSSFWorkbook(dataStream); dataStream.close(); } catch (GeneralSecurityException ex) { throw new Exception("Unable to read and parse encrypted document", ex); } finally { if (dataStream != null) { try { dataStream.close(); } catch (IOException ioe) { // ignore } } if (fin != null) { try { fin.close(); } catch (IOException ioe) { // ignore } } } readPassword = null; } else { FileInputStream fin = new FileInputStream(inputFile); try { workbook = new XSSFWorkbook(fin); } finally { if (fin != null) { try { fin.close(); } catch (IOException ioe) { // ignore } } } } } } } else { // create new workbooks if (currentType == SpreadsheetTyp.XLS) { workbook = new HSSFWorkbook(); } else if (currentType == SpreadsheetTyp.XLSX) { if (createStreamingXMLWorkbook) { workbook = new SXSSFWorkbook(new XSSFWorkbook(), rowAccessWindow); } else { workbook = new XSSFWorkbook(); } } } setupDataFormatStyle(); }
From source file:jp.qpg.ExcelTo.java
License:Apache License
/** * command/*www. ja v a2 s. c o m*/ * * @param args [-p password] [-m true|false(draw margin line if true)] Excel files(.xls, .xlsx, .xlsm) */ public static void main(String[] args) { Objects.requireNonNull(args); int count = 0; boolean[] drawMarginLine = { false }; for (int i = 0; i < args.length; i++) { switch (args[i]) { case "-m":/* set draw margin line */ i++; drawMarginLine[0] = Boolean.parseBoolean(args[i]); break; case "-p":/* set password */ i++; Biff8EncryptionKey.setCurrentUserPassword(args[i]); break; default: String path = Tool.trim(args[i], "\"", "\""); String toPath = Tool.changeExtension(path, ".pdf"); String toTextPath = Tool.changeExtension(path, ".txt"); try (InputStream in = Files.newInputStream(Paths.get(path)); Workbook book = WorkbookFactory.create(in); OutputStream out = Files.newOutputStream(Paths.get(toPath)); OutputStream outText = Files.newOutputStream(Paths.get(toTextPath))) { logger.info("processing: " + path); pdf(book, out, printer -> { printer.setPageSize(PDRectangle.A4, false); printer.setFontSize(10.5f); printer.setMargin(15); printer.setLineSpace(5); printer.setDrawMarginLine(drawMarginLine[0]); }); text(book, outText); logger.info("converted: " + toPath + ", " + toTextPath); count++; } catch (IOException e) { throw new UncheckedIOException(e); } break; } } logger.info("processed " + count + " files."); }
From source file:org.apache.tika.parser.microsoft.ExcelExtractor.java
License:Apache License
protected void parse(DirectoryNode root, XHTMLContentHandler xhtml, Locale locale) throws IOException, SAXException, TikaException { if (!root.hasEntry(WORKBOOK_ENTRY)) { if (root.hasEntry(BOOK_ENTRY)) { // Excel 5 / Excel 95 file // Records are in a different structure so needs a // different parser to process them OldExcelExtractor extractor = new OldExcelExtractor(root); OldExcelParser.parse(extractor, xhtml); return; } else {//from w w w . ja va 2 s. co m // Corrupt file / very old file, just skip text extraction return; } } // If a password was supplied, use it, otherwise the default Biff8EncryptionKey.setCurrentUserPassword(getPassword()); // Have the file processed in event mode TikaHSSFListener listener = new TikaHSSFListener(xhtml, locale, this); listener.processFile(root, isListenForAllRecords()); listener.throwStoredException(); for (Entry entry : root) { if (entry.getName().startsWith("MBD") && entry instanceof DirectoryEntry) { try { handleEmbeddedOfficeDoc((DirectoryEntry) entry, xhtml); } catch (TikaException e) { // ignore parse errors from embedded documents } } } }
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) {/* w w w.j ava 2 s. c om*/ 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"); }