Initiates the processing of the XLS workbook file to CSV.

@throws IOException
@throws OpenXML4JException
@throws ParserConfigurationException
@throws SAXException
519798
public List<String> process() throws IOException, OpenXML4JException, ParserConfigurationException, SAXException {
		ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(this.xlsxPackage);
		XSSFReader xssfReader = new XSSFReader(this.xlsxPackage);
		StylesTable styles = xssfReader.getStylesTable();
		XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
		int index = 0;
		while (iter.hasNext()) {
			if(blankRowNum == 10)break;
			InputStream stream = iter.next();
			String sheetName = iter.getSheetName();
			results.add(ExcelValidator.SHEET_NAME_PREFIX + sheetName);
			processSheet(styles, strings, new SheetToCSV(), stream);
			stream.close();
			++index;
		}

		return results;
	}
633275
private void parse(Workbook ws) throws ParseException {
    LOG.info("Parsing XLS file...");
    Sheet sheet = ws.getSheet(SHEET_NAME);
    if (sheet == null) {
      sheet = ws.getSheetAt(0);
    }
    if (sheet == null) {
      throw new ParseException("No sheet found");
    }

    int firstRow = sheet.getFirstRowNum();
    int lastRow = sheet.getLastRowNum();
    LOG.info("first row is:" + firstRow + ", last row is:" + lastRow);

    // first row is expected to be the header.
    analyzeHeader(sheet.getRow(firstRow));

    for (int i = firstRow + 1; i <= lastRow; i++) {
      Row r = sheet.getRow(i);
      extractRowData(r, cellMap);
    }
    LOG.info("Parsing of XLS file finished.");
  }
116538
@Override
public void close() throws IOException {
	try {
		// prepare metadata
		prepareMetaData();
		
		// write
		if (this.oStream!=null) {
			if (this.howc.getPassword()==null) { // no encryption
				finalizeWriteNotEncrypted();
			} else 	// encryption
				if (this.currentWorkbook instanceof HSSFWorkbook) { // old Excel format
					finalizeWriteEncryptedHSSF();
				} else if (this.currentWorkbook instanceof XSSFWorkbook) {
					finalizeWriteEncryptedXSSF();
					}
				 else {
					LOG.error("Could not write encrypted workbook, because type of workbook is unknown");
				}

			}
		} finally {

			// close filesystems
			if (this.ooxmlDocumentFileSystem!=null)  {
				 ooxmlDocumentFileSystem.close();
			}

		// close main workbook
		if (this.currentWorkbook!=null) {
			this.currentWorkbook.close();
		}
		
		// close linked workbooks
		 	for (Workbook currentWorkbookItem: this.listOfWorkbooks) {
				if (currentWorkbookItem!=null) {
					currentWorkbookItem.close();
				}
			}
		}
	try {
	// do we need to sign => sign
	if (this.signUtil!=null) {
		// sign
		LOG.info("Signing document \""+this.howc.getFileName()+"\"");
		if (this.howc.getSigCertificate()==null) {
			LOG.error("Cannot sign document \""+this.howc.getFileName()+"\". No certificate for key provided");
		} else if (!(this.currentWorkbook instanceof XSSFWorkbook)){
			LOG.warn("Signing of docuemnts in old Excel format not supported for \""+this.howc.getFileName()+"\"");
		}else {
		try {
				ArrayList<X509Certificate> certList = new ArrayList<>();
				certList.add(this.howc.getSigCertificate());
				this.signUtil.sign(this.howc.getSigKey(), certList, this.howc.getPassword(), MSExcelWriter.getHashAlgorithm(this.howc.getSigHash()));
		} catch (XMLSignatureException|MarshalException|IOException|FormatNotUnderstoodException e) {
			LOG.error("Cannot sign document \""+this.howc.getFileName()+"\" "+e);
		}
			
		}
		
	}
	} finally {
		if (this.signUtil!=null) {
			this.signUtil.close();
		}
	}
}
1350561
public void startDocument() throws SAXException {
        traceBuilder.delete(0, traceBuilder.length());
        trace("startDocument");
        currentDocument = documentBuilder.newDocument();
        currentElement = null;
    }
245518
public void generateCSV() {
        
        int cont = 0;
        int algorithmSize = this.streams.get(0).algorithm.size();
        int streamSize = this.streams.size();
        int measureSize = this.streams.get(0).algorithm.get(0).measures.size();
        
        while (cont != measureSize) {
            String output = "";
            output += "Algorithm,";
            output += this.streams.get(0).algorithm.get(0).name;
            //Inicialize summary table
            
            for (int i = 1; i < algorithmSize; i++) {
                output += "," + this.streams.get(0).algorithm.get(i).name;
               
            }
            output += "\n";

            for (int i = 0; i < streamSize; i++) {
                List<Algorithm> alg = this.streams.get(i).algorithm;
                output += this.streams.get(i).name;
                for (int j = 0; j < algorithmSize; j++) {
                    output += "," + alg.get(j).measures.get(cont).getValue();
                    
                }
                output += "\n";
            }
            //PrintStream out = null;
            String name = this.streams.get(0).algorithm.get(0).measures.get(cont).getName();
//            try {
//                out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path + name + ".csv")));
//            } catch (FileNotFoundException ex) {
//                Logger.getLogger(Summary.class.getName()).log(Level.SEVERE, null, ex);
//            }
//            System.setOut(out);
//            System.out.println(output);
//            out.close();
            try {
            BufferedWriter out = new BufferedWriter(new FileWriter(path + name + ".csv"));
            out.write(output);  //Replace with the string 
            //you are trying to write  
            out.close();
        } catch (IOException e) {
            System.out.println(name + ".csv");

        }
            cont++;
        }

    }
618071
protected void startDocumentInternal() throws org.xml.sax.SAXException
    {
        super.startDocumentInternal();

        m_needToCallStartDocument = false; 
        m_needToOutputDocTypeDecl = true;
        m_startNewLine = false;
        setOmitXMLDeclaration(true);
    }
845278
@Override
    public Process importProcess(File from) throws IOException {
        try {
            Process process = new Process();
            String name = from.getName();
            int lastDot = name.lastIndexOf('.');
            if (lastDot > 0 && lastDot < name.length() - 1)
                name = name.substring(0, lastDot);
            process.setName(name);
            process.setAttribute(Display.NAME, "x=25,y=25,w=0,h=0");
            MxGraphParser graph = importGraph(new FileInputStream(from));
            process.setActivities(graph.getActivities());
            process.setTransitions(graph.getTransitions());
            if (!graph.getTextNotes().isEmpty()) {
                process.setTextNotes(graph.getTextNotes());
            }
            return process;
        }
        catch (SAXException | ParserConfigurationException ex) {
            throw new IOException(ex.getMessage(), ex);
        }
    }
1164163
public void build() throws IOException {
        if (! serialClassFoundToDocument(configuration.root.classes())) {
            //Nothing to document.
            return;
        }
        try {
            writer = configuration.getWriterFactory().getSerializedFormWriter();
            if (writer == null) {
                //Doclet does not support this output.
                return;
            }
        } catch (Exception e) {
            throw new DocletAbortException(e);
        }
        build(layoutParser.parseXML(NAME), contentTree);
        writer.close();
    }
1284725
public void load(String filename) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    loadMessages(builder.parse(new CSFileInputStream(filename)));
  }
173024
public void writeXmlDocument(Document document, File file) throws IOException {
        try {
            Transformer tr = transformerFactory.newTransformer();
            tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            tr.setOutputProperty(OutputKeys.INDENT, "yes");
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            tr.transform(new DOMSource(document), new StreamResult(fileOutputStream));
            fileOutputStream.close();
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        }
    }
281891
public void writeExcelFile() throws IOException, WriteException {
        WritableWorkbook excelWrkBook = null;
        int curDsPointer = 0;

        try {
            final String[] columnNames = ds.getColumns();
            final List<String> exportOnlyColumnsList = getExportOnlyColumns() != null ? Arrays.asList(exportOnlyColumns) : null;
            final List<String> excludeFromExportColumnsList = getExcludeFromExportColumns() != null ? Arrays.asList(excludeFromExportColumns) : null;
            final List<String> numericColumnList = getNumericColumns() != null ? Arrays.asList(getNumericColumns()) : new ArrayList<>();
            // get the current position of the DataSet. We have to go to the top
            // to do this write,
            // and we will put the pionter back where it was after we are done
            curDsPointer = ds.getIndex();
            ds.goTop();

            excelWrkBook = Workbook.createWorkbook(xlsFile);
            final WritableSheet wrkSheet = excelWrkBook.createSheet("results", 0);

            final WritableFont times10ptBold = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD);
            final WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10, WritableFont.NO_BOLD);
            // write the column headings in the spreadsheet
            WritableCellFormat cellFormat = new WritableCellFormat(times10ptBold);
            int colOffset = 0;
            for (int i = 0; i < columnNames.length; i++) {
                if (exportOnlyColumnsList != null && !exportOnlyColumnsList.contains(columnNames[i])
                        || excludeFromExportColumnsList != null && excludeFromExportColumnsList.contains(columnNames[i])) {
                    colOffset++;
                    continue;
                }

                final Label xlsTextLbl = new Label(i - colOffset, 0, columnNames[i], cellFormat);
                wrkSheet.addCell(xlsTextLbl);
            }

            cellFormat = new WritableCellFormat(times10pt);
            int row = 1;
            while (ds.next()) {
                if (!ds.isRecordID(FPConstants.DETAIL_ID)) {
                    continue;
                }

                colOffset = 0;
                for (int i = 0; i < columnNames.length; i++) {
                    if (exportOnlyColumnsList != null && !exportOnlyColumnsList.contains(columnNames[i])
                            || excludeFromExportColumnsList != null && excludeFromExportColumnsList.contains(columnNames[i])) {
                        colOffset++;
                        continue;
                    }

                    WritableCell wc = null;
                    if (numericColumnList.contains(columnNames[i])) {
                        wc = new Number(i - colOffset, row, ds.getDouble(columnNames[i]), cellFormat);
                    } else {
                        wc = new Label(i - colOffset, row, ds.getString(columnNames[i]), cellFormat);
                    }

                    wrkSheet.addCell(wc);
                }

                row++;
            }

            excelWrkBook.write();

        } finally {
            if (curDsPointer > -1) {
                ds.absolute(curDsPointer);
            }
            if (excelWrkBook != null) {
                excelWrkBook.close();
            }
        }

    }
237267
def xl_to_csv(infile, outfile)
    filepath = File.expand_path(infile)
    puts "xl_to_csv: #{infile} => #{outfile}" if verbose?

    unless File.exists?(filepath)
      puts "Unable to find file."
      puts "  #{filepath}"
      return
    end

    #   Open an Excel file
    xl_app.open_workbook filepath

    # Build a list of work sheets to dump to file.
    sheets_in_file = []

    sheet_saved_count = 0

    xl_app.worksheet_names.each do |sheetname|
      if( sheetname.match(/CQDS/) || sheetname.match(/PLK/) )
        sheets_in_file << sheetname
        puts "Converting sheet #{sheetname}" if verbose?
        sheet_saved_count += 1
      end
    end

    if (1 > sheet_saved_count)
      puts "*** No sheets labeled 'PLK' or 'CQDS' ***"
      puts "Verify #{infile} is formatted correctly."
      # Close Excel
      xl_app.close_workbook
      return
    end

    # Write sheet data to file.
    File.open(outfile, "w") do |f|
      data = xl_app.worksheet_data(sheets_in_file[0])
      for row in data
        row_data = []
        for a_cell in row
          row_data << process_cell_value(a_cell)
        end

        contains_data = false

        # Determine if the row contains any data.
        for cell in row_data
          if(cell.match(/[^,\r\n]+/))
            contains_data = true
          end
        end

        # Insert an empty line if the row contains no data.
        if(true == contains_data)
          f << row_data.join(",")
          f << "\n"

          if(true == verbose?)
            puts "#{row_data}"
          end

        else
          f << "\n"

          if(true == verbose?)
            puts "\n"
          end
        end
      end
    end

    # Strip empty data from end of lines
    clean_csv(outfile)

    # Close Excel
    xl_app.close_workbook
  end
979313
def xlsx_to_csv(self, infile, worksheet=0, delimiter=","):
        
        wb = load_workbook(self.getInputFile())
        sheet = wb.worksheets[worksheet]
        buffer = StringIO()

        # extract all rows
        for n, row in enumerate(sheet.rows):
            line = []
            for cell in row:
                value = cell.value
                if type(value) in types.StringTypes:
                    value = value.encode("utf8")
                if value is None:
                    value = ""
                line.append(str(value))
            print >>buffer, delimiter.join(line)
        buffer.seek(0)
        return buffer
634492
@Override
	public void open(FileInputSplit split) throws IOException {
		// read Excel
		super.open(split);
		// infer schema (requires to read file again)
		if (this.customSchema == null) {
			ExcelFlinkFileInputFormat effif = new ExcelFlinkFileInputFormat(this.shocr);
			effif.open(split);
			SpreadSheetCellDAO[] currentRow = effif.nextRecord(null);
			int i = 0;
			while ((currentRow != null) && (i != this.maxInferRows)) {
				this.converter.updateSpreadSheetCellRowToInferSchemaInformation(currentRow);
				i++;
				currentRow = effif.nextRecord(null);
			}
			effif.close();
			this.customSchema = this.converter.getSchemaRow();
		} else {
			this.converter.setSchemaRow(this.customSchema);
		}
	}
185231
public void readDump() throws IOException {
		try {
			SAXParserFactory factory = SAXParserFactory.newInstance();
			factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
			SAXParser parser = factory.newSAXParser();
	
			parser.parse(input, this);
		} catch (ParserConfigurationException e) {
			throw (IOException)new IOException(e.getMessage()).initCause(e);
		} catch (SAXException e) {
			throw (IOException)new IOException(e.getMessage()).initCause(e);
		}
		writer.close();
	}
311732
public void process() throws CDKException {
        logger.debug("Started parsing from input...");
        try {
            parser.setFeature("http://xml.org/sax/features/validation", false);
            logger.info("Deactivated validation");
        } catch (SAXException e) {
            logger.warn("Cannot deactivate validation.");
        }
        parser.setContentHandler(new EventCMLHandler(this, builder));
        parser.setEntityResolver(new CMLResolver());
        parser.setErrorHandler(new CMLErrorHandler());
        try {
            logger.debug("Parsing from Reader");
            parser.parse(new InputSource(input));
        } catch (IOException e) {
            String error = "Error while reading file: " + e.getMessage();
            logger.error(error);
            logger.debug(e);
            throw new CDKException(error, e);
        } catch (SAXParseException saxe) {
            SAXParseException spe = (SAXParseException) saxe;
            String error = "Found well-formedness error in line " + spe.getLineNumber();
            logger.error(error);
            logger.debug(saxe);
            throw new CDKException(error, saxe);
        } catch (SAXException saxe) {
            String error = "Error while parsing XML: " + saxe.getMessage();
            logger.error(error);
            logger.debug(saxe);
            throw new CDKException(error, saxe);
        }
    }
700282
private void writeRowsToCSV(List<String[]> rows) throws BindException
  {
    int numBytes;
    int rowNum = 0;
    int fileCount = 0;

    while (rowNum < rows.size())
    {
      File file = getFile(++fileCount);

      try (OutputStream out = openFile(file))
      {
        // until we reach the last row or the file is too big, write to the file
        numBytes = 0;
        while (numBytes < fileSize && rowNum < rows.size())
        {
          byte[] csv = createCSVRecord(rows.get(rowNum));
          numBytes += csv.length;
          out.write(csv);
          rowNum++;
        }
      }
      catch (IOException ex)
      {
        throw new BindException(
            String.format("Exception encountered while writing to file: %s", ex.getMessage()), BindException.Type.SERIALIZATION);
      }
    }
  }