• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OpenXML4JException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.poi.openxml4j.exceptions.OpenXML4JException的典型用法代码示例。如果您正苦于以下问题:Java OpenXML4JException类的具体用法?Java OpenXML4JException怎么用?Java OpenXML4JException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OpenXML4JException类属于org.apache.poi.openxml4j.exceptions包,在下文中一共展示了OpenXML4JException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: unmarshal

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> List<T> unmarshal(Class<T> type) {
    try (OPCPackage open = OPCPackage.open(poijiFile.file())) {

        ReadOnlySharedStringsTable readOnlySharedStringsTable = new ReadOnlySharedStringsTable(open);
        XSSFReader xssfReader = new XSSFReader(open);
        StylesTable styles = xssfReader.getStylesTable();

        SheetIterator iter = (SheetIterator) xssfReader.getSheetsData();
        int index = 0;

        while (iter.hasNext()) {
            try (InputStream stream = iter.next()) {
                if (index == options.sheetIndex()) {
                    return processSheet(styles, readOnlySharedStringsTable, type, stream);
                }
            }
            ++index;
        }
        return new ArrayList<>();
    } catch (SAXException | IOException | OpenXML4JException e) {
        throw new PoijiException("Problem occurred while reading data", e);
    }
}
 
开发者ID:ozlerhakan,项目名称:poiji,代码行数:26,代码来源:XSSFUnmarshaller.java


示例2: processAll

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
private void processAll(OPCPackage pkg)
		throws IOException, OpenXML4JException, InvalidFormatException, SAXException {
	XSSFReader xssfReader = new XSSFReader(pkg);
	mStylesTable = xssfReader.getStylesTable();
	SharedStringsTable sst = xssfReader.getSharedStringsTable();
	XMLReader parser = this.fetchSheetParser(sst);
	Iterator<InputStream> sheets = xssfReader.getSheetsData();
	while (sheets.hasNext()) {
		mCurrentRowIndex = 0;
		mSheetIndex++;
		InputStream sheet = sheets.next();
		InputSource sheetSource = new InputSource(sheet);
		parser.parse(sheetSource);
		sheet.close();
	}
	pkg.close();
}
 
开发者ID:wuwz,项目名称:ExcelKit,代码行数:18,代码来源:XlsxReader.java


示例3: processBySheet

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
private void processBySheet(int sheetIndex, OPCPackage pkg)
		throws IOException, OpenXML4JException, InvalidFormatException, SAXException {
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();

	XMLReader parser = fetchSheetParser(sst);

	// rId2 found by processing the Workbook
	// 根据 rId# 或 rSheet# 查找sheet
	InputStream sheet = r.getSheet("rId" + (sheetIndex + 1));
	mSheetIndex++;
	InputSource sheetSource = new InputSource(sheet);
	parser.parse(sheetSource);
	sheet.close();
	pkg.close();
}
 
开发者ID:wuwz,项目名称:ExcelKit,代码行数:17,代码来源:XlsxReader.java


示例4: process

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
/**
 * Initiates the processing of the XLS workbook file to CSV.
 *
 * @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);
    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;
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:27,代码来源:XLSX2CSV.java


示例5: microsoftExcelDocumentToString

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
private static String microsoftExcelDocumentToString(InputStream inputStream) throws IOException, OpenXML4JException, XmlException {
    StringBuilder sb = new StringBuilder();

    try (InputStream excelStream = new BufferedInputStream(inputStream)) {
        if (POIFSFileSystem.hasPOIFSHeader(excelStream)) { // Before 2007 format files
            POIFSFileSystem excelFS = new POIFSFileSystem(excelStream);
            ExcelExtractor excelExtractor = new ExcelExtractor(excelFS);
            sb.append(excelExtractor.getText());
            excelExtractor.close();
        } else { // New format
            XSSFWorkbook workBook = new XSSFWorkbook(excelStream);
            int numberOfSheets = workBook.getNumberOfSheets();
            for (int i = 0; i < numberOfSheets; i++) {
                XSSFSheet sheet = workBook.getSheetAt(0);
                Iterator<Row> rowIterator = sheet.rowIterator();
                while (rowIterator.hasNext()) {
                    XSSFRow row = (XSSFRow) rowIterator.next();
                    Iterator<Cell> cellIterator = row.cellIterator();
                    while (cellIterator.hasNext()) {
                        XSSFCell cell = (XSSFCell) cellIterator.next();
                        sb.append(cell.toString());
                        sb.append(" ");
                    }
                    sb.append("\n");
                }
                sb.append("\n");
            }
        }
    }

    return sb.toString();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:33,代码来源:IndexerUtils.java


示例6: LowMemXlsReader

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
public LowMemXlsReader( InputStream stream ) throws IOException {
	log.debug( "reading with lo-mem xls reader" );
	sharedStrings = new ArrayList<>();
	try {
		pkg = OPCPackage.open( stream );
		reader = new XSSFReader( pkg );

		styles = reader.getStylesTable();

		sheetNameIdLkp = readSheetInfo( reader );
		populateSharedStrings( reader );
	}
	catch ( OpenXML4JException e ) {
		throw new IOException( "unexpected error" + e.getLocalizedMessage(), e );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:17,代码来源:LowMemXlsReader.java


示例7: process

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
/**
 * Initiates the processing of the XLS workbook file to CSV.
 *
 * @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);
	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;
}
 
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:27,代码来源:XLSX2CSV.java


示例8: readStreamToList

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public void readStreamToList(InputStream stream,
                             ReaderCondition[] conditions, BingReadListener listener)
        throws IOException, SQLException, OpenXML4JException, SAXException {
    this.listener = listener;
    BingExcelReaderListener listner = new BingExcelReaderListener(
            conditions);
    ReadHandler handler = ExcelReaderFactory.create(stream, listner, true);
    int[] indexArr = new int[conditions.length];
    int minNum = 0;
    for (int i = 0; i < conditions.length; i++) {
        int sheetNum = conditions[i].getSheetIndex();
        indexArr[i] = sheetNum;
        if (minNum > conditions[i].getEndRow()) {
            minNum = conditions[i].getEndRow();
        }
    }
    handler.readSheet(indexArr, minNum);
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:20,代码来源:BingExcelEventImpl.java


示例9: readStreamToList

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public List<SheetVo> readStreamToList(InputStream stream, ReaderCondition[] conditions) throws IOException, SQLException, OpenXML4JException, SAXException {
  List<SheetVo> resultList = Lists.newArrayList();
  BingExcelReaderListener listner = new BingExcelReaderListener(conditions, resultList);
  ReadHandler handler = ExcelReaderFactory.create(stream, listner, true);
  int[] indexArr = new int[conditions.length];
  int minNum = 0;
  for (int i = 0; i < conditions.length; i++) {
    int sheetNum = conditions[i].getSheetIndex();
    indexArr[i] = sheetNum;
    if (minNum > conditions[i].getEndRow()) {
      minNum = conditions[i].getEndRow();
    }
  }
  handler.readSheet(indexArr, minNum);
  return resultList;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:18,代码来源:BingExcelImpl.java


示例10: streamSheetByName

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public void streamSheetByName(String sheetName) throws IOException, SAXException, OpenXML4JException, ParserConfigurationException, SheetNotFoundException {
    if (sheetName == null) {
        throw new IllegalArgumentException("SheetName can't be null!");
    } else if (sheetName.isEmpty()) {
        throw new IllegalArgumentException("SheetName can't be empty!");
    }
    XSSFReader streamer = new XSSFReader(pack);
    SheetIterator sheetIterator = (SheetIterator) streamer.getSheetsData();

    int sheetNumber = 0;
    InputStream stream;

    while (sheetIterator.hasNext()) {
        stream = sheetIterator.next();
        if (sheetIterator.getSheetName().contentEquals(sheetName)) {
            dataCallback.onBegin();
            streamSheet(streamer, stream, sheetNumber);
            dataCallback.onEnd();
            return;
        }
        sheetNumber++;
    }
    throw new SheetNotFoundException(sheetName);
}
 
开发者ID:iMDT,项目名称:xlsx-io,代码行数:26,代码来源:XlsxStreamer.java


示例11: streamSheetByIndex

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public void streamSheetByIndex(int index) throws IOException, SAXException, OpenXML4JException, ParserConfigurationException, SheetNotFoundException {
    if (index < 0) {
        throw new IllegalArgumentException("Index must be higher than -1!");
    }

    XSSFReader streamer = new XSSFReader(pack);
    SheetIterator sheetIterator = (SheetIterator) streamer.getSheetsData();
    int sheetNumber = 0;
    InputStream stream;

    while (sheetIterator.hasNext()) {
        stream = sheetIterator.next();

        if (sheetNumber == index) {
            dataCallback.onBegin();
            streamSheet(streamer, stream, sheetNumber);
            dataCallback.onEnd();
            return;
        }
        sheetNumber++;
    }

    throw new SheetNotFoundException(index);
}
 
开发者ID:iMDT,项目名称:xlsx-io,代码行数:26,代码来源:XlsxStreamer.java


示例12: getSheetIndexBySheetName

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
/**
 * Fetch the index of the sheet by its name.
 *
 * @param sheetName
 * @return The sheet index, -1 otherwise
 * @throws IOException
 * @throws SAXException
 * @throws OpenXML4JException
 */
public int getSheetIndexBySheetName(String sheetName) throws IOException, SAXException, OpenXML4JException {
    if (sheetName == null) {
        throw new IllegalArgumentException("SheetName can't be null!");
    } else if (sheetName.isEmpty()) {
        throw new IllegalArgumentException("SheetName can't be empty!");
    }
    int index = 0;
    XSSFReader streamer = new XSSFReader(pack);
    SheetIterator sheetIterator = (SheetIterator) streamer.getSheetsData();

    while (sheetIterator.hasNext()) {
        sheetIterator.next();
        if (sheetIterator.getSheetName().contentEquals(sheetName)) {
            return index;
        }
        index++;
    }

    return -1;
}
 
开发者ID:iMDT,项目名称:xlsx-io,代码行数:30,代码来源:XlsxMetadata.java


示例13: parseXlsxFileAndWriteTmxBody

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
public void parseXlsxFileAndWriteTmxBody(String fileName, AbstractWriter tmxWriter, IProgressMonitor monitor)
		throws ParserConfigurationException, SAXException, IOException, OpenXML4JException {
	this.tmxWriter = tmxWriter;
	this.monitor = monitor;
	File file = new File(fileName);
	long length = file.length();
	monitor.beginTask("", countTotal(length));
	OPCPackage p = OPCPackage.open(fileName, PackageAccess.READ);
	ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(p);
	XSSFReader xssfReader = new XSSFReader(p);
	XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
	try {
		while (iter.hasNext()) {
			InputStream stream = iter.next();
			parse(stream, strings, tmxWriter);
			stream.close();
			// 目前只处理第一个sheet
			break;
		}
	} finally {
		p.close();
	}

	monitor.done();
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:26,代码来源:Xlsx2TmxHelper.java


示例14: readRows

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
public void readRows(IProgressMonitor monitor) throws ParserConfigurationException, SAXException, IOException, OpenXML4JException {
	monitor.beginTask("", 10);
	monitor.worked(1);
	OPCPackage p = OPCPackage.open(xlsxFile, PackageAccess.READ);
	ReadOnlySharedStringsTable shareString = new ReadOnlySharedStringsTable(p);
	XSSFReader xssfReader = new XSSFReader(p);
	XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
	try {
		while (iter.hasNext()) {
			InputStream stream = iter.next();
			readCells(stream, shareString, new SubProgressMonitor(monitor, 9));
			stream.close();
			// 目前只处理第一个sheet
			break;
		}
	} finally {
		p.close();
		monitor.done();
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:XlsxRowReader.java


示例15: process

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
/**
 * Initiates the processing of the XLS workbook file to CSV.
 *
 * @throws IOException
 * @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;
    }
}
 
开发者ID:nagirrab,项目名称:xls2csv,代码行数:26,代码来源:XlsxToCsv.java


示例16: readSheet

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public void readSheet(int[] indexs, int maxReadLine) throws IOException,
		OpenXML4JException, SAXException {
		setMaxReturnLine(maxReadLine);
		readSheet(indexs);

}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:8,代码来源:DefaultHSSFHandler.java


示例17: readStream

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public <T> void readStream(InputStream stream, Class<T> clazz,
                           int startRowNum, BingReadListener listener) throws IOException,
        SQLException, OpenXML4JException, SAXException {
    readStream(stream, new ReaderCondition<T>(0, startRowNum, clazz),
            listener);
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:8,代码来源:BingExcelEventImpl.java


示例18: readStream

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public <T> SheetVo<T> readStream(InputStream stream, ReaderCondition<T> condition) throws IOException, SQLException, OpenXML4JException, SAXException {
  ReaderCondition[] arr = new ReaderCondition[] {condition};
  List<SheetVo> list = readStreamToList(stream, arr);
  return list.size() == 0 ? null : list.get(0);
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:8,代码来源:BingExcelImpl.java


示例19: stream

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
@Override
public void stream() throws IOException, SAXException, OpenXML4JException, ParserConfigurationException {
    
    XSSFReader streamer = new XSSFReader(pack);
    SheetIterator sheetIterator = (SheetIterator) streamer.getSheetsData();
    dataCallback.onBegin();
    int sheetNumber = 1;
    while (sheetIterator.hasNext()) {
        streamSheet(streamer, sheetIterator.next(), sheetNumber);
        sheetNumber++;
    }
    dataCallback.onEnd();
}
 
开发者ID:iMDT,项目名称:xlsx-io,代码行数:14,代码来源:XlsxStreamer.java


示例20: getSheetNames

import org.apache.poi.openxml4j.exceptions.OpenXML4JException; //导入依赖的package包/类
/**
 * Fetch the list of sheet names presented in a XLSX
 *
 * @return list of sheet names.
 * @throws IOException
 * @throws SAXException
 * @throws OpenXML4JException
 */
public List<String> getSheetNames() throws IOException, SAXException, OpenXML4JException {
    ArrayList<String> sheetNames = new ArrayList<String>();

    XSSFReader streamer = new XSSFReader(pack);
    SheetIterator sheetIterator = (SheetIterator) streamer.getSheetsData();

    while (sheetIterator.hasNext()) {
        sheetIterator.next();
        sheetNames.add(sheetIterator.getSheetName());
    }

    return sheetNames;
}
 
开发者ID:iMDT,项目名称:xlsx-io,代码行数:22,代码来源:XlsxMetadata.java



注:本文中的org.apache.poi.openxml4j.exceptions.OpenXML4JException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PvmActivity类代码示例发布时间:2022-05-21
下一篇:
Java Calls类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap