List of usage examples for org.apache.poi.ss.usermodel Workbook getSheetAt
Sheet getSheetAt(int index);
From source file:controller.VisitasController.java
public void autoSizeColumns(Workbook workbook) { int numberOfSheets = workbook.getNumberOfSheets(); for (int i = 0; i < numberOfSheets; i++) { Sheet sheet = workbook.getSheetAt(i); if (sheet.getPhysicalNumberOfRows() > 0) { Row row = sheet.getRow(8);/*w w w . j a v a 2s. c o m*/ Iterator<Cell> cellIterator = row.cellIterator(); while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); int columnIndex = cell.getColumnIndex(); sheet.autoSizeColumn(columnIndex); } } } }
From source file:controllers.TargetController.java
License:Open Source License
private static void excelParser(File inputFile) throws Throwable { FileInputStream file = new FileInputStream(inputFile); //Create Workbook instance holding reference to .xls[x] file Workbook workbook = WorkbookFactory.create(file); //Get first/desired sheet from the workbook Sheet sheet = workbook.getSheetAt(0); // Check total row: if (sheet.getPhysicalNumberOfRows() <= 1) { throw new Exception("Sheet should have at least one row."); }//from ww w. j a v a 2 s . co m Logger.debug("Sheet has " + sheet.getPhysicalNumberOfRows() + " rows."); //Iterate through each rows one by one Iterator<Row> rowIterator = sheet.iterator(); // Header row: Row header = rowIterator.next(); Logger.debug("HEADER: " + header); // TODO Check header row is right. // And the rest: StringBuilder sb = new StringBuilder(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); // Get Target target = new Target(); target.title = row.getCell(0).getStringCellValue(); target.fieldUrls = new ArrayList<FieldUrl>(); // Check URL FieldUrl url = new FieldUrl(row.getCell(1).getStringCellValue()); target.fieldUrls.add(url); FieldUrl existingFieldUrl = FieldUrl.findByUrl(url.url); if (existingFieldUrl != null) { String error = "Row # " + row.getRowNum() + ": CONFLICT - URL " + existingFieldUrl.url + " is already part of target " + existingFieldUrl.target.id + "\n"; Logger.debug(error); sb.append(error); continue; } //Collection c = new Collection(); //c.name = // System.out.println(target); // TODO Merge with controllers.ApplicationController.bulkImport() code to avoid repetition. target.revision = Const.INITIAL_REVISION; target.active = true; target.selectionType = Const.SelectionType.SELECTION.name(); if (target.noLdCriteriaMet == null) { target.noLdCriteriaMet = Boolean.FALSE; } if (target.keySite == null) { target.keySite = Boolean.FALSE; } if (target.ignoreRobotsTxt == null) { target.ignoreRobotsTxt = Boolean.FALSE; } // Save - disabled right now, as we do not want this live as yet. /* target.runChecks(); target.save(); */ // System.out.println(target); } workbook.close(); file.close(); // And report errors if (sb.length() > 0) { throw (new Exception(sb.toString())); } }
From source file:coolmap.application.io.external.ImportCOntologyFromXLS.java
@Override public void importFromFile(File inFile) throws Exception { if (!proceed) { throw new Exception("Import from excel was cancelled"); }// w w w . ja v a2s . co m try { String fileNameString = inFile.getName().toLowerCase(); FileInputStream inStream = new FileInputStream(inFile); Workbook workbook = null; if (fileNameString.endsWith("xls")) { workbook = new HSSFWorkbook(inStream); } else if (fileNameString.toLowerCase().endsWith("xlsx")) { workbook = new XSSFWorkbook(inStream); } Sheet sheet = workbook.getSheetAt(sheetIndex); COntology ontology = new COntology(Tools.removeFileExtension(fileNameString), null); if (formatIndex == SIF) { importSIF(sheet, ontology); } else if (formatIndex == GMT) { importGMT(sheet, ontology); } ontology.validate(); ontologies.add(ontology); // COntologyUtils.printOntology(ontology); } catch (Exception e) { throw new Exception("File error"); } }
From source file:coolmap.application.io.external.ImportCOntologyFromXLS.java
@Override public void configure(File... file) { try {// w w w .j a v a2 s . c o m File inFile = file[0]; String fileNameString = inFile.getName().toLowerCase(); FileInputStream inStream = new FileInputStream(inFile); Workbook workbook = null; if (fileNameString.endsWith("xls")) { workbook = new HSSFWorkbook(inStream); } else if (fileNameString.toLowerCase().endsWith("xlsx")) { workbook = new XSSFWorkbook(inStream); } int sheetCount = workbook.getNumberOfSheets(); String[] sheetNames = new String[sheetCount]; for (int i = 0; i < sheetNames.length; i++) { String sheetName = workbook.getSheetAt(i).getSheetName(); sheetNames[i] = sheetName == null || sheetName.length() == 0 ? "Untitled" : sheetName; } DefaultTableModel tableModels[] = new DefaultTableModel[sheetCount]; Cell cell; Row row; ArrayList<ArrayList<ArrayList<Object>>> previewData = new ArrayList(); for (int si = 0; si < sheetCount; si++) { //The row iterator automatically skips the blank rows //so only need to figure out how many rows to skip; which is nice //columns, not the same though Sheet sheet = workbook.getSheetAt(si); Iterator<Row> rowIterator = sheet.rowIterator(); int ri = 0; ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>(); while (rowIterator.hasNext()) { row = rowIterator.next(); ArrayList<Object> rowData = new ArrayList<>(); for (int j = 0; j < row.getLastCellNum(); j++) { cell = row.getCell(j); try { if (cell == null) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { rowData.add(cell.getStringCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { rowData.add(cell.getNumericCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { rowData.add(cell.getBooleanCellValue()); } else { rowData.add(cell.toString()); } } catch (Exception e) { // CMConsole.logError(" error parsing excel cell: " + cell + ", [" + ri + "," + j + "]"); rowData.add(null); } } data.add(rowData); ri++; if (ri == previewNum) { break; } } //end // System.out.println(data); // now the data is the data // ugh-> this is not a generic importer previewData.add(data); } //end of loop sheets ConfigPanel configPanel = new ConfigPanel(sheetNames, previewData); int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), configPanel, "Import from Excel: " + inFile.getAbsolutePath(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { proceed = true; inStream.close(); workbook = null; //set parameters inFile = file[0]; rowStart = configPanel.getRowStart(); columnStart = configPanel.getColumnStart(); sheetIndex = configPanel.getSheetIndex(); formatIndex = configPanel.getFormatIndex(); } else { //mark operation cancelled proceed = false; } } catch (Exception e) { } }
From source file:coolmap.application.io.external.ImportDataFromXLS.java
@Override public void importFromFile(File inFile) throws Exception { //Ignore the file, choose only a single file //I actually don't know the row count if (!proceed) { throw new Exception("Import from excel was cancelled"); } else {// w ww. j ava 2 s . c o m try { String fileNameString = inFile.getName().toLowerCase(); FileInputStream inStream = new FileInputStream(inFile); Workbook workbook = null; if (fileNameString.endsWith("xls")) { workbook = new HSSFWorkbook(inStream); } else if (fileNameString.toLowerCase().endsWith("xlsx")) { workbook = new XSSFWorkbook(inStream); } Sheet sheet = workbook.getSheetAt(sheetIndex); int rowCounter = 0; //need to first copy the file over ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>(); Iterator<Row> rowIterator = sheet.rowIterator(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); // if (rowCounter < rowStart) { // rowCounter++; // //import ontology rows // // continue; // // //skip first rows // } ArrayList<Object> rowData = new ArrayList<Object>(); for (int i = 0; i < row.getLastCellNum(); i++) { Cell cell = row.getCell(i); // System.out.print(cell + " "); // now add data try { if (cell == null) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { rowData.add(cell.getStringCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { rowData.add(cell.getNumericCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { rowData.add(cell.getBooleanCellValue()); } else { rowData.add(cell.toString()); } } catch (Exception e) { // CMConsole.logError(" error parsing excel cell: " + cell + ", [" + row + "," + i + "]"); rowData.add(null); } } // System.out.println(""); data.add(rowData); } //now I have row data int rowCount = data.size() - rowStart - 1; int columnCount = data.get(0).size() - columnStart - 1; DoubleCMatrix matrix = new DoubleCMatrix(Tools.removeFileExtension(inFile.getName()), rowCount, columnCount); String[] rowNames = new String[rowCount]; String[] columnNames = new String[columnCount]; for (int i = rowStart; i < data.size(); i++) { ArrayList row = data.get(i); if (i == rowStart) { //first row contains names for (int j = columnStart + 1; j < row.size(); j++) { try { columnNames[j - columnStart - 1] = row.get(j).toString(); } catch (Exception e) { columnNames[j - columnStart - 1] = "Untitled " + Tools.randomID(); } } continue; } for (int j = columnStart; j < row.size(); j++) { Object cell = row.get(j); if (j == columnStart) { try { rowNames[i - rowStart - 1] = cell.toString(); } catch (Exception e) { rowNames[i - rowStart - 1] = "Untitled" + Tools.randomID(); } } else { //set values try { Object value = (Double) row.get(j); if (value == null) { matrix.setValue(i - rowStart - 1, j - columnStart - 1, null); } else if (value instanceof Double) { matrix.setValue(i - rowStart - 1, j - columnStart - 1, (Double) value); } else { matrix.setValue(i - rowStart - 1, j - columnStart - 1, Double.NaN); } } catch (Exception e) { matrix.setValue(i - rowStart - 1, j - columnStart - 1, null); } } } //end of iterating columns } //end of iterating rows // matrix.printMatrix(); // matrix.setRowLabels(rowNames); matrix.setColLabels(columnNames); CoolMapObject object = new CoolMapObject(); object.setName(Tools.removeFileExtension(inFile.getName())); object.addBaseCMatrix(matrix); ArrayList<VNode> nodes = new ArrayList<VNode>(); for (Object label : matrix.getRowLabelsAsList()) { nodes.add(new VNode(label.toString())); } object.insertRowNodes(nodes); nodes.clear(); for (Object label : matrix.getColLabelsAsList()) { nodes.add(new VNode(label.toString())); } object.insertColumnNodes(nodes); object.setAggregator(new DoubleDoubleMean()); object.setSnippetConverter(new DoubleSnippet1_3()); object.setViewRenderer(new NumberToColor(), true); object.getCoolMapView().addColumnMap(new ColumnLabels(object)); object.getCoolMapView().addColumnMap(new ColumnTree(object)); object.getCoolMapView().addRowMap(new RowLabels(object)); object.getCoolMapView().addRowMap(new RowTree(object)); importedCoolMaps.clear(); importedCoolMaps.add(object); //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// // //let's add COntologies if (columnStart > 0) { COntology columnOntology = new COntology( Tools.removeFileExtension(inFile.getName()) + " column ontology", null); ArrayList<Object> columnLabels = data.get(rowStart); //these are column labels for (int i = 0; i < rowStart; i++) { ArrayList ontologyColumn = data.get(i); for (int j = columnStart + 1; j < columnLabels.size(); j++) { Object parent = ontologyColumn.get(j); Object child = columnLabels.get(j); if (parent != null && child != null) { columnOntology.addRelationshipNoUpdateDepth(parent.toString(), child.toString()); } //Also need to create presets } } columnOntology.validate(); // COntologyUtils.printOntology(columnOntology); importedOntologies.add(columnOntology); // need to finish the preset } if (rowStart > 0) { COntology rowOntology = new COntology( Tools.removeFileExtension(inFile.getName()) + " row ontology", null); List rowLabels = Arrays.asList(rowNames); for (int j = 0; j < columnStart; j++) { for (int i = rowStart + 1; i < data.size(); i++) { Object parent = data.get(i).get(j); Object child = rowLabels.get(i - rowStart - 1); if (parent != null && child != null) { rowOntology.addRelationshipNoUpdateDepth(parent.toString(), child.toString()); } } } rowOntology.validate(); COntologyUtils.printOntology(rowOntology); importedOntologies.add(rowOntology); } // create row and column complex combinatorial ontology (intersections) } catch (Exception e) { // e.printStackTrace(); throw new Exception("File error"); } } }
From source file:coolmap.application.io.external.ImportDataFromXLS.java
@Override public void configure(File... file) { //need to popup a secondary dialog; this must be done differently try {//from w w w .ja va 2s . co m File inFile = file[0]; String fileNameString = inFile.getName().toLowerCase(); FileInputStream inStream = new FileInputStream(inFile); Workbook workbook = null; if (fileNameString.endsWith("xls")) { workbook = new HSSFWorkbook(inStream); } else if (fileNameString.toLowerCase().endsWith("xlsx")) { workbook = new XSSFWorkbook(inStream); } int sheetCount = workbook.getNumberOfSheets(); String[] sheetNames = new String[sheetCount]; for (int i = 0; i < sheetNames.length; i++) { String sheetName = workbook.getSheetAt(i).getSheetName(); sheetNames[i] = sheetName == null || sheetName.length() == 0 ? "Untitled" : sheetName; } //also need to get the top 100 rows + all columns DefaultTableModel tableModels[] = new DefaultTableModel[sheetCount]; Cell cell; Row row; ArrayList<ArrayList<ArrayList<Object>>> previewData = new ArrayList(); for (int si = 0; si < sheetCount; si++) { //The row iterator automatically skips the blank rows //so only need to figure out how many rows to skip; which is nice //columns, not the same though Sheet sheet = workbook.getSheetAt(si); Iterator<Row> rowIterator = sheet.rowIterator(); int ri = 0; ArrayList<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>(); while (rowIterator.hasNext()) { row = rowIterator.next(); ArrayList<Object> rowData = new ArrayList<>(); for (int j = 0; j < row.getLastCellNum(); j++) { cell = row.getCell(j); try { if (cell == null) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { rowData.add(null); } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { rowData.add(cell.getStringCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { rowData.add(cell.getNumericCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { rowData.add(cell.getBooleanCellValue()); } else { rowData.add(cell.toString()); } } catch (Exception e) { // CMConsole.logError(" error parsing excel cell: " + cell + ", [" + ri + "," + j + "]"); rowData.add(null); } } data.add(rowData); ri++; if (ri == previewNum) { break; } } //end // System.out.println(data); // now the data is the data // ugh-> this is not a generic importer previewData.add(data); } //end of iterating all sheets ConfigPanel configPanel = new ConfigPanel(sheetNames, previewData); //int returnVal = JOptionPane.showMessageDialog(CoolMapMaster.getCMainFrame(), configPanel); int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(), configPanel, "Import from Excel: " + inFile.getAbsolutePath(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null); if (returnVal == JOptionPane.OK_OPTION) { proceed = true; inStream.close(); workbook = null; //set parameters inFile = file[0]; importOntology = configPanel.getImportOntology(); rowStart = configPanel.getRowStart(); columnStart = configPanel.getColumnStart(); sheetIndex = configPanel.getSheetIndex(); } else { //mark operation cancelled proceed = false; } } catch (Exception e) { CMConsole.logError(" failed to import numeric matrix data from: " + file); e.printStackTrace(); } }
From source file:Core.Core.java
public void printRes(double[] rapport, int[] errorForCouple, double[] dataQuality, int[] real, int noEnc) { StringTokenizer st = new StringTokenizer(Extractor.dpsFileLocation); st.nextToken("-"); st.nextToken("-"); String name = st.nextToken("_"); //int numOfPage = 4; try {// w ww. ja v a 2s .c o m String filename = "/home/gabriele/Documenti/risultati prophetSpy/result " + name + ".xlsx"; FileInputStream fileInput = null; Sheet sheet; Workbook workbook = null; try { fileInput = new FileInputStream(filename); workbook = create(fileInput); sheet = workbook.getSheetAt(0); System.out.println("found xlsx file"); } catch (FileNotFoundException fileNotFoundException) { workbook = new XSSFWorkbook(); sheet = workbook.createSheet("foglio 1"); System.out.println("no file found"); } Row rowhead = sheet.createRow(0); rowhead.createCell(0).setCellValue("rapport"); rowhead.createCell(1).setCellValue("errorForCouple"); rowhead.createCell(2).setCellValue("dataQuality"); rowhead.createCell(3).setCellValue("real"); rowhead.createCell(7).setCellValue("est = 0"); rowhead.createCell(8).setCellValue("Total Couple"); int numRow = 1; for (int j = 0; j < rapport.length; j++) { if (rapport[j] != -1) { Row row = sheet.createRow(numRow); row.createCell(0).setCellValue(rapport[j]); row.createCell(1).setCellValue(errorForCouple[j]); row.createCell(2).setCellValue(dataQuality[j]); row.createCell(3).setCellValue(real[j]); numRow++; } } sheet.getRow(1).createCell(7).setCellValue(noEnc); sheet.getRow(1).createCell(8).setCellValue(rapport.length); FileOutputStream fileOut = new FileOutputStream(filename); workbook.write(fileOut); fileOut.close(); System.out.println("Your excel file has been generated!"); } catch (Exception ex) { System.out.println(ex); } }
From source file:crygetter.gui.MainWindow.java
/** * Loads Cry Data (order affect)/*from w w w. j a v a2s . c om*/ */ private void loadCryData() { try { Workbook wb = WorkbookFactory.create(getClass().getResourceAsStream("/cryData.xlsx")); Sheet sheet = wb.getSheetAt(0); Row orderNameRow = sheet.getRow(1); cryOrderData = new LinkedHashMap<>(); for (int i = 2;; i++) { Cell orderNameCell = orderNameRow.getCell(i); if (orderNameCell != null) { List<String> affectList = new ArrayList<>(); for (int j = 2;; j++) { Row orderValueRow = sheet.getRow(j); if (orderValueRow != null) { Cell cryValueCell = orderValueRow.getCell(1); Cell orderValueCell = orderValueRow.getCell(i); if (orderValueCell != null && !orderValueCell.getStringCellValue().equals("")) { String value = orderValueCell.getStringCellValue(); if (value.equals("A") || value.equals("P")) { affectList.add("Cry" + cryValueCell.getStringCellValue()); } } } else { break; } } if (!affectList.isEmpty()) { cryOrderData.put(orderNameCell.getStringCellValue(), affectList); } } else { break; } } } catch (IOException | InvalidFormatException exc) { Utils.showExceptionMessage(this, exc); } }
From source file:crygetter.gui.MainWindow.java
/** * Loads Amino Acid Data/*from w w w . j a v a2 s . co m*/ */ private void loadAAData() { try { Workbook wb = WorkbookFactory.create(getClass().getResourceAsStream("/aaData.xlsx")); Sheet sheet = wb.getSheetAt(0); aaData = new LinkedHashMap<>(); for (int i = 1;; i++) { Row aaDataRow = sheet.getRow(i); if (aaDataRow != null) { String name = aaDataRow.getCell(0).getStringCellValue(); String threeLetter = aaDataRow.getCell(1).getStringCellValue(); String oneLetter = aaDataRow.getCell(2).getStringCellValue(); String group = aaDataRow.getCell(3).getStringCellValue(); String sideChainGroup = aaDataRow.getCell(4).getStringCellValue(); String sideChainPolarity = aaDataRow.getCell(5).getStringCellValue(); String sideChainCharge = aaDataRow.getCell(6).getStringCellValue(); String hydropathyIndex = aaDataRow.getCell(7).getStringCellValue(); String molecularMass = aaDataRow.getCell(8).getStringCellValue(); String vanderWaalsVolume = aaDataRow.getCell(9).getStringCellValue(); String frequencyInProteins = aaDataRow.getCell(10).getStringCellValue(); String surfaceArea = aaDataRow.getCell(11).getStringCellValue(); String[] observations = aaDataRow.getCell(12).getStringCellValue().split("[$]"); AminoAcid aa = new AminoAcid(); aa.name = name; aa.threeLetter = threeLetter; aa.oneLetter = oneLetter; aa.group = group; aa.sideChainGroup = sideChainGroup; aa.sideChainPolarity = sideChainPolarity; aa.sideChainCharge = sideChainCharge; aa.hydropathyIndex = hydropathyIndex; aa.molecularMass = molecularMass; aa.vanderWaalsVolume = vanderWaalsVolume; aa.frequencyInProteins = frequencyInProteins; aa.surfaceArea = surfaceArea; aa.observations.addAll(Arrays.asList(observations)); aa.pdbFile = "/" + threeLetter.toLowerCase() + ".pdb"; aa.pngFile = "/" + threeLetter.toLowerCase() + ".png"; aaData.put(oneLetter, aa); } else { break; } } } catch (IOException | InvalidFormatException exc) { Utils.showExceptionMessage(this, exc); } }
From source file:das.pf.io.IOExcel.java
License:Open Source License
public boolean processFile(Path input, boolean openFile) { boolean result = false; int endRow = 0; try {/*from ww w . ja va 2 s. com*/ updateMessages(String.format("Inicializando el documento: %s", input.toString())); Path copy = createCopy(input); if (copy != null && Files.exists(copy, LinkOption.NOFOLLOW_LINKS)) { Workbook workbook = WorkbookFactory.create(copy.toFile()); Sheet sheet = workbook.getSheetAt(0); Sheet newSheet = workbook.createSheet("Procesado"); workbook.setSheetName(0, "Crudo"); endRow = getLasRow(sheet); // seccion para la creacion de los encabezados updateMessages("Creando la cabecera de los datos"); createHeaderData(newSheet, getCellStyleHeaderData(workbook)); // seccion para los values USD updateMessages( String.format("Creando la cabecera para los: 'values USD' %s", TypeUnits.MTH.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.VALUES, TypeUnits.MTH), 11, 35, 14); updateMessages( String.format("Creando la cabecera para los: 'values USD' %s", TypeUnits.QRT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.VALUES, TypeUnits.QRT), 35, 49, 38); updateMessages( String.format("Creando la cabecera para los: 'values USD' %s", TypeUnits.YTD.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.VALUES, TypeUnits.YTD), 49, 54, 52); updateMessages( String.format("Creando la cabecera para los: 'values USD' %s", TypeUnits.MAT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.VALUES, TypeUnits.MAT), 54, 59, 57); // seccion para los values units updateMessages( String.format("Creando la cabecera para los: 'values Units' %s", TypeUnits.MTH.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.UNITS, TypeUnits.MTH), 59, 83, 63); updateMessages( String.format("Creando la cabecera para los: 'values Units' %s", TypeUnits.QRT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.UNITS, TypeUnits.QRT), 83, 97, 87); updateMessages( String.format("Creando la cabecera para los: 'values Units' %s", TypeUnits.YTD.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.UNITS, TypeUnits.YTD), 97, 102, 101); updateMessages( String.format("Creando la cabecera para los: 'values Units' %s", TypeUnits.MAT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.UNITS, TypeUnits.MAT), 102, 107, 106); // // // seccion para los values units standars updateMessages(String.format("Creando la cabecera para los: 'values Standard Units' %s", TypeUnits.MTH.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.U_E, TypeUnits.MTH), 107, 131, 112); updateMessages(String.format("Creando la cabecera para los: 'values Standard Units' %s", TypeUnits.QRT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.U_E, TypeUnits.QRT), 131, 145, 136); updateMessages(String.format("Creando la cabecera para los: 'values Standard Units' %s", TypeUnits.YTD.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.U_E, TypeUnits.YTD), 145, 150, 150); updateMessages(String.format("Creando la cabecera para los: 'values Standard Units' %s", TypeUnits.MAT.name())); createHeaderValues(newSheet, sheet, getCellStyleValues(workbook, TypeValues.U_E, TypeUnits.MAT), 150, 155, 155); // fin de la seccion para la creacion de los encabezados // seccion para escribir los CT updateMessages("Escribiendo las clases terampeuticas..."); writeCT(newSheet, sheet, 13, endRow); // seccion para escribir los productos updateMessages("Escribiendo los productos..."); writeProducts(newSheet, sheet, 14); // seccion para escribir los otros valores updateMessages("Escribiendo datos en general..."); writerOthersValues(newSheet, sheet, 15); // seccion para escribir los key competitors updateMessages("Escribiendo los Key Competitors..."); writeKeyCompetitors(newSheet, 3, endRow, 9, 5); // seccion para escribir el pais XmlContry contry = writeContries(newSheet, 3, 0, input); // seccion para escribir la region writeRegions(contry, newSheet, 3, 1); for (int i = 0; i < 155; i++) newSheet.autoSizeColumn(i); newSheet.setAutoFilter(CellRangeAddress.valueOf(String.format("A3:K%d", newSheet.getLastRowNum()))); String pathOutput = "DAS PF - " + input.getFileName().toString(); try (FileOutputStream fos = new FileOutputStream( Paths.get(this.out.toString(), pathOutput).toFile())) { updateMessages(String.format("Guadando el trabajo en la ruta: '%s'", Paths.get(this.out.toString(), pathOutput))); workbook.write(fos); } catch (IOException ex) { Logger.getLogger(IOExcel.class.getName()).log(Level.SEVERE, null, ex); } finally { workbook.close(); } if (openFile && Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) Desktop.getDesktop().open(Paths.get(this.out.toString(), pathOutput).toFile()); result = true; newSheet = null; sheet = null; workbook = null; Files.delete(copy); } } catch (IOException | InvalidFormatException ex) { Logger.getLogger(IOExcel.class.getName()).log(Level.SEVERE, null, ex); Util.showException("No se pudo guardar el archivo", ex); } return result; }