List of usage examples for org.apache.poi.xssf.eventusermodel XSSFReader getStylesTable
public StylesTable getStylesTable() throws IOException, InvalidFormatException
From source file:com.test.demo.ccbpay.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * * @throws IOException/* www . j a va 2 s. co m*/ * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ private 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 it = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); while (it.hasNext()) { InputStream stream = it.next(); processSheet(styles, strings, new SheetToCSV(this.minColumns), stream); stream.close(); } return this.rows; }
From source file:com.test.excel.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * /* ww w. jav a 2s . co m*/ * @throws IOException * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public void process() throws IOException, OpenXML4JException, ParserConfigurationException, SAXException { List<String[]> list = null; 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()) { InputStream stream = iter.next(); String sheetName = iter.getSheetName(); list = processSheet(styles, strings, stream); stream.close(); ++index; } System.out.println(list); close(); }
From source file:com.toolsverse.etl.connector.excel.ExcelXlsxConnector.java
License:Open Source License
/** * Initiates the processing of the XLS workbook file. * * @param xlsxPackage the xlsx package//from www . j a v a 2 s. c o m * @param sheetName the sheet name * @param params the params * @param dataSet the data set * @param driver the driver * @throws IOException Signals that an I/O exception has occurred. * @throws OpenXML4JException the open xm l4 j exception * @throws ParserConfigurationException the parser configuration exception * @throws SAXException the sAX exception */ public void process(OPCPackage xlsxPackage, String sheetName, ExcelConnectorParams params, DataSet dataSet, Driver driver) throws IOException, OpenXML4JException, ParserConfigurationException, SAXException { ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(xlsxPackage); XSSFReader xssfReader = new XSSFReader(xlsxPackage); StylesTable styles = xssfReader.getStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); while (iter.hasNext()) { InputStream stream = iter.next(); try { if (sheetName.equals(iter.getSheetName())) { processSheet(styles, strings, stream, params, dataSet, driver); return; } } finally { stream.close(); } } }
From source file:com.tsm.xlstocsv.XlsxToCsv.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * * @throws IOException/*from www.j a v a 2 s .co m*/ * @throws org.apache.poi.openxml4j.exceptions.OpenXML4JException * @throws javax.xml.parsers.ParserConfigurationException * @throws org.xml.sax.SAXException */ public void 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()) { InputStream stream = iter.next(); PrintStream output = dispatcher.openStreamForSheet(iter.getSheetName()); processSheet(styles, strings, stream, output); dispatcher.closeStreamForSheet(output, iter.getSheetName()); stream.close(); ++index; } }
From source file:com.ufo.util.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * // w w w .ja va 2 s. co m * @throws IOException * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public void 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()) { InputStream stream = iter.next(); String sheetName = iter.getSheetName(); // this.output.println(); // this.output.println(sheetName + " [index=" + index + "]:"); processSheet(styles, strings, stream); stream.close(); ++index; } }
From source file:com.xipin.est.ucontroller.excel.ExcelImportXLSXUtil.java
License:Apache License
/** * ??? /*from w w w .j a v a 2 s . c o m*/ * * @throws IOException * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public List<String[]> process() throws IOException, OpenXML4JException, ParserConfigurationException, SAXException { ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(this.xlsxPackage); XSSFReader xssfReader = new XSSFReader(this.xlsxPackage); List<String[]> list = null; StylesTable styles = xssfReader.getStylesTable(); XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData(); while (iter.hasNext()) { InputStream stream = iter.next(); String sheetNameTemp = iter.getSheetName(); if (this.sheetName.equals(sheetNameTemp)) { list = processSheet(styles, strings, stream); stream.close(); } } return list; }
From source file:de.unioninvestment.eai.portal.portlet.crud.export.streaming.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * //from w w w . ja v a 2 s. com * @throws IOException * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public void 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()) { InputStream stream = iter.next(); String sheetName = iter.getSheetName(); processSheet(styles, strings, stream); stream.close(); ++index; } }
From source file:excel.XSSF.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * * @throws IOException If reading the data from the package fails. * @throws SAXException if parsing the XML data fails. *///from ww w . j a v a 2 s.c om public void process() throws IOException, OpenXML4JException, 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()) { InputStream stream = iter.next(); String sheetName = iter.getSheetName(); this.output.println(); // this.output.println(sheetName + " [index=" + index + "]:"); this.output.println(String.format("\"%s\":[", sheetName)); processSheet(styles, strings, new SheetToCSV(), stream); stream.close(); this.output.println("]"); ++index; } }
From source file:extract.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * * @throws IOException/*from ww w . jav a 2 s . c o m*/ * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public void 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()) { InputStream stream = iter.next(); String sheetName = iter.getSheetName(); this.output.println(); this.output.println(sheetName + " [index=" + index + "]:"); processSheet(styles, strings, new SheetToCSV(), stream); stream.close(); ++index; } }
From source file:kiklos.tv.timetable.XLSX2CSV.java
License:Apache License
/** * Initiates the processing of the XLS workbook file to CSV. * /*w ww . j a v a2 s. c om*/ * @throws IOException * @throws OpenXML4JException * @throws ParserConfigurationException * @throws SAXException */ public void 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()) { InputStream stream = iter.next(); //String sheetName = iter.getSheetName(); //this.output.println(); //this.output.println(sheetName + " [index=" + index + "]:"); processSheet(styles, strings, stream); stream.close(); ++index; return; // todo: need only first sheet !!!!! } }