Returns the sheets from the given Excel XLSX file.
@param stream The input stream with the XLSX file
@return The sheet names from the XLSX file
@throws IOException if the file cannot be opened
2607
public static String[] getXlsxWorksheets(InputStream stream) 
        throws IOException
    {
        XlsxWorkbook workbook = XlsxWorkbook.getWorkbook(stream);
        String[] sheets = workbook.getSheetNames();
        workbook.close();
        return sheets;
    }
683230
public List<String> process() throws IOException {
		MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(this);
		formatListener = new FormatTrackingHSSFListener(listener);

		HSSFEventFactory factory = new HSSFEventFactory();
		HSSFRequest request = new HSSFRequest();

		if(outputFormulaValues) {
			request.addListenerForAllRecords(formatListener);
		} else {
			workbookBuildingListener = new SheetRecordCollectingListener(formatListener);
			request.addListenerForAllRecords(workbookBuildingListener);
		}

		factory.processWorkbookEvents(request, fs);
		
		return results;
	}
765386
public static List<?> xls2List(String xmlPath, InputStream inputStream) throws Exception {
        return XlsUtil.xls2List(xmlPath, inputStream);
    }
878652
public static Map<String, Object> read(InputStream stream)
		throws IOException
	{
		ConfigJsonInput input = new ConfigJsonInput(new InputStreamReader(stream, StandardCharsets.UTF_8));
		return read(input);
	}
1074944
public void write2Stream(OutputStream os) throws Excel4JException {

        try {
            this.workbook.write(os);
        } catch (IOException e) {
            throw new Excel4JException(e);
        }
    }
115760
public static List<?> xls2List(String xmlPath, File xlsFile) throws Exception {
        return XlsUtil.xls2List(xmlPath, xlsFile);
    }
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;
	}
685000
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
        return XlsUtil.list2Xls(config, list, outputStream);
    }
436967
public static boolean list2Xls(List<?> list, String xmlPath, OutputStream outputStream) throws Exception {
        try {
            ExcelConfig config = getEasyExcel(xmlPath);
            return list2Xls(config, list, outputStream);
        } catch (Exception e1) {
            return false;
        }
    }
52666
public Map<String,InputStream> loadLinkedWorkbooks(String[] fileNames) throws IOException {
	HashMap<String,InputStream> result = new HashMap<>();
	if (fileNames==null) {
		return result;
	}
	for (String currentFile: fileNames) {
		Path currentPath=new Path(currentFile);
		InputStream currentInputStream = openFile(currentPath);
		result.put(currentPath.getName(), currentInputStream); 
	}
	return result;
}
1152052
@Programmatic
    public <T> List<T> fromExcel(
            final Blob excelBlob,
            final WorksheetSpec worksheetSpec) throws ExcelService.Exception {
        final List<List<?>> listOfList =
                fromExcel(excelBlob, Collections.singletonList(worksheetSpec));
        return (List<T>) listOfList.get(0);
    }
1262956
public List<String[]> parse(InputStream stream) throws IOException
    {
        int columnCount = -1;
        List<String[]> lines = new ArrayList<String[]>();
        rows.clear();

        // Excel spreadsheet
        if(CommonFiles.isExcelFile(name))
        {
            if(worksheet != null && worksheet.length() > 0)
            {
                SimpleDateFormat df = new SimpleDateFormat(Formats.DATETIME_FORMAT);
                df.setTimeZone(TimeZone.getTimeZone("GMT"));

                Workbook workbook = Workbook.getWorkbook(name, stream);
                Worksheet sheet = workbook.getSheet(worksheet);
                if(sheet != null)
                {
                    columnCount = sheet.getColumns();
                    for(int i = 0; i < sheet.getRows(); i++)
                    {
                        String[] values = sheet.getRow(i, df);
                        if(values != null)
                            lines.add(values);
                    }
                }
                else
                {
                    throw new IllegalStateException("Worksheet '"+worksheet+"' not found");
                }

                workbook.close();
            }
            else
            {
                throw new IllegalArgumentException("Worksheet not specified");
            }
        }
        else if(CommonFiles.isCsvFile(name))
        {
            Reader reader = new InputStreamReader(stream);
            CSVReader csv = new CSVReader(reader, delimiter.separator().charAt(0));
            String [] line;
            while ((line = csv.readNext()) != null) 
            {
                if(columnCount == -1)
                    columnCount = line.length;
                lines.add(line);
            }
            reader.close();
        }

        int lineCount = lines.size();

        logger.fine("InputFileReader.parse: lines="+lineCount+" columns="+columnCount);

        // Error if the file is empty
        if(lineCount <= 0 || columnCount == 0)
            throw new IllegalStateException("input file does not contain any data");

        // Parse the file headers and rows
        int count = 0;
        for(String[] line : lines)
        {
            // Ignore the line if there is no data
            if(isBlankRow(line))
                continue;

            String[] row = new String[columnCount];  // the row of data

            for(int column = 0; column < columnCount; column++)
            {

                // Check that the row column count matches the header column count
                if(column >= line.length)
                {
                    if(line.length > 0 && isCompleteLine(line))
                        break;
                    else
                        throw new IllegalStateException("Row "+count+" has more columns than the header row");
                }

                // The first row gives the column headers
                if(count == 0)
                {
                    try
                    {
                        row[column] = line[column].trim();
                    }
                    catch(NoSuchElementException e)
                    {
                        row[column] = "";
                    }
                }
                else // The subsequent rows give the actual data
                {
                    try
                    {
                        String token = line[column];

                        // Remove quotes
                        if(removeQuotes && token.startsWith("\""))
                        {
                            token = token.substring(1);
                            if(token.endsWith("\""))
                                token = token.substring(0,token.length()-1);

                            // Replace all other double quotes with a single quote
                            token = token.replaceAll("\"\"", "\"");
                        }

                        // Trim the value (if required)
                        if(trim)
                            token.trim();

                        // Put the processed token in the array
                        row[column] = token;
                        logger.fine("InputFileReader.parse: row["+count+","+headers[column]+"]="+token);
                    }
                    catch(NoSuchElementException e)
                    {
                        row[column] = "";
                    }
                }
            }

            if(count == 0)
                headers = row;
            else
                rows.add(row);
            ++count;
        }

        return rows;
    }
1205433
public <T> List<T> readCSV2Objects(InputStream is, Class<T> clazz) {

        try {
            return readCSVByMapHandler(is, clazz);
        } catch (Excel4JException | IOException e) {
            throw new Excel4jReadException("read CSV Error: ", e);
        }
    }
1085644
private byte[] getExcelOutput(FileColumn[] columns, List<String[]> lines) throws IOException
    {
        // Create the workbook
        baos = new ByteArrayOutputStream(1024);
        if(existing != null)
            workbook = Workbook.createWorkbook(format, baos, existing);
        else
            workbook = Workbook.createWorkbook(format, baos);

        workbook.setHeaders(hasHeaders());

        if(append && workbook.getSheet(worksheet) != null)
            workbook.appendToSheet(columns, lines, worksheet);
        else
            workbook.createSheet(columns, lines, worksheet);

        // Write out the workbook to the stream
        workbook.write();
        workbook.close();

        // The contents returned is the byte array
        return baos.toByteArray();
    }
1136626
public static List<String> readLines(InputStream input) throws IOException {
        final InputStreamReader reader = new InputStreamReader(input);
        return readLines(reader);
    }
1091536
public static String fromStream(InputStream stream) throws IOException {
		if (stream != null) {			
			try {
				Writer writer = new StringWriter();
				Reader reader = new BufferedReader(new InputStreamReader(stream));
				int read;
				while ((read = reader.read()) != -1) {
					writer.write(read);
				}
				return writer.toString();
			} finally {
				try {
					stream.close();
				} catch(IOException e) {
					logger.warn("error closing the input stream", e);
				}
			}			
		}
		return null;
	}
1049546
public void normalSheet2Excel(List<NormalSheetWrapper> sheetWrappers, String templatePath, OutputStream os)
            throws Excel4JException {

        try (SheetTemplate sheetTemplate = exportExcelByModuleHandler(templatePath, sheetWrappers)) {
            sheetTemplate.write2Stream(os);
        } catch (IOException e) {
            throw new Excel4JException(e);
        }
    }