本文整理汇总了Java中org.apache.poi.xssf.model.StylesTable类的典型用法代码示例。如果您正苦于以下问题:Java StylesTable类的具体用法?Java StylesTable怎么用?Java StylesTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StylesTable类属于org.apache.poi.xssf.model包,在下文中一共展示了StylesTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processSheet
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> List<T> processSheet(StylesTable styles, ReadOnlySharedStringsTable readOnlySharedStringsTable,
Class<T> type, InputStream sheetInputStream) {
DataFormatter formatter = new DataFormatter();
InputSource sheetSource = new InputSource(sheetInputStream);
try {
XMLReader sheetParser = SAXHelper.newXMLReader();
PoijiHandler poijiHandler = new PoijiHandler(type, options);
ContentHandler contentHandler =
new XSSFSheetXMLHandler(styles, null, readOnlySharedStringsTable, poijiHandler, formatter, false);
sheetParser.setContentHandler(contentHandler);
sheetParser.parse(sheetSource);
return poijiHandler.getDataset();
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new PoijiException("Problem occurred while reading data", e);
}
}
示例2: unmarshal
import org.apache.poi.xssf.model.StylesTable; //导入依赖的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);
}
}
示例3: process
import org.apache.poi.xssf.model.StylesTable; //导入依赖的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;
}
示例4: XSSFSheetXMLHandlerPlus
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
/**
* Accepts objects needed while parsing.
*
* @param styles Table of styles
* @param strings Table of shared strings
*/
public XSSFSheetXMLHandlerPlus(
StylesTable styles,
CommentsTable comments,
ReadOnlySharedStringsTable strings,
XSSFSheetXMLHandlerPlus.SheetContentsHandler sheetContentsHandler,
DataFormatter dataFormatter,
boolean formulasNotResults) {
this.stylesTable = styles;
this.commentsTable = comments;
this.sharedStringsTable = strings;
this.output = sheetContentsHandler;
this.formulasNotResults = formulasNotResults;
this.nextDataType = XSSFSheetXMLHandlerPlus.xssfDataType.NUMBER;
this.formatter = dataFormatter;
init();
}
示例5: process
import org.apache.poi.xssf.model.StylesTable; //导入依赖的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;
}
示例6: ContentHandlerImpl
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
/**
* Default constructor of {@link ContentHandlerImpl}
*
* @param sheetNumber The sheet number
* @param dataCallback
* @param styles Table of styles
* @param sharedStringsTable Table of shared strings
* @param dataHandler The handler to be delivered when data cell is ready to
* @param ignoreEmptyRow If it should ignore missing/empty rows.
* be used
*/
public ContentHandlerImpl(long sheetNumber,
DataCallback dataCallback,
StylesTable styles,
ReadOnlySharedStringsTable sharedStringsTable,
DataHandler dataHandler,boolean ignoreEmptyRow) {
this.stylesTable = styles;
this.sharedStringsTable = sharedStringsTable;
this.bufferedReadedValue = new StringBuffer();
this.sheetNumber = sheetNumber;
this.dataCallback = dataCallback;
this.currentCol = -1;
this.rawValues = new NotNullList();
this.formattedValues = new NotNullList();
this.dataTypeService = new XlsxDataTypeServiceImpl();
if (dataHandler == null) {
this.dataHandler = new DefaultDataHandlerImpl(rawValues, formattedValues, sharedStringsTable);
} else {
this.dataHandler = dataHandler;
}
this.ignoreEmptyRow = ignoreEmptyRow;
}
示例7: processSheet
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
public void processSheet(SheetContentsHandler sheetContentsExtractor,
StylesTable styles, ReadOnlySharedStringsTable strings,
InputStream sheetInputStream) throws IOException, SAXException {
InputSource sheetSource = new InputSource(sheetInputStream);
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
try {
SAXParser saxParser = saxFactory.newSAXParser();
XMLReader sheetParser = saxParser.getXMLReader();
XSSFSheetInterestingPartsCapturer handler = new XSSFSheetInterestingPartsCapturer(
new XSSFSheetXMLHandler(styles, strings, sheetContentsExtractor,
formatter, false));
sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource);
sheetInputStream.close();
if (handler.hasProtection) {
metadata.set(TikaMetadataKeys.PROTECTED, "true");
}
} catch (ParserConfigurationException e) {
throw new RuntimeException("SAX parser appears to be broken - "
+ e.getMessage());
}
}
示例8: parseCSVFromSheet
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
private Map<Integer, Map<Integer, Object>> parseCSVFromSheet(InputStream sheetInputStream, StylesTable stylesTable, SharedStringsTable sharedStringsTable)
{
try
{
Map<Integer, Map<Integer, Object>> sheet = new HashMap<Integer, Map<Integer, Object>>();
XMLReader sheetParser = XMLReaderFactory.createXMLReader();
ContentHandler sheetHandler = new SheetHandler(sheet, stylesTable, sharedStringsTable);
sheetParser.setContentHandler(sheetHandler);
InputSource sheetSource = new InputSource(sheetInputStream);
sheetParser.parse(sheetSource);
sheetInputStream.close();
return sheet;
}
catch (Throwable throwable)
{
logger.log(Level.WARNING, "Sheet conversion to CSV", throwable);
return null;
}
}
开发者ID:arjuna-technologies,项目名称:Apache-POI_DataBroker_PlugIn,代码行数:23,代码来源:XSSFStreamSheetToCSVDataProcessor.java
示例9: loadSheets
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
void loadSheets(XSSFReader reader, SharedStringsTable sst, StylesTable stylesTable, int rowCacheSize) throws IOException, InvalidFormatException,
XMLStreamException {
lookupSheetNames(reader);
//Some workbooks have multiple references to the same sheet. Need to filter
//them out before creating the XMLEventReader by keeping track of their URIs.
//The sheets are listed in order, so we must keep track of insertion order.
SheetIterator iter = (SheetIterator) reader.getSheetsData();
Map<URI, InputStream> sheetStreams = new LinkedHashMap<>();
while(iter.hasNext()) {
InputStream is = iter.next();
sheetStreams.put(iter.getSheetPart().getPartName().getURI(), is);
}
//Iterate over the loaded streams
int i = 0;
for(URI uri : sheetStreams.keySet()) {
XMLEventReader parser = StaxHelper.newXMLInputFactory().createXMLEventReader(sheetStreams.get(uri));
sheets.add(new StreamingSheet(sheetProperties.get(i++).get("name"), new StreamingSheetReader(sst, stylesTable, parser, use1904Dates, rowCacheSize)));
}
}
示例10: importSchema
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
private SchemaSheetInformation importSchema(XSSFReader r,StylesTable styles ,ReadOnlySharedStringsTable sst ){
try {
XSSFReader.SheetIterator it = (XSSFReader.SheetIterator) r.getSheetsData();
while(it.hasNext()) {
try(InputStream sheet = it.next()){
String name = it.getSheetName();
if(Strings.equalsStd(PoiIO.SCHEMA_SHEET_NAME, name)){
InputSource sheetSource = new InputSource(sheet);
ReadSchemaSheet readSchemaSheet = new ReadSchemaSheet();
parseSheet(styles, sst, sheetSource, readSchemaSheet);
return readSchemaSheet.finish(report);
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
示例11: processSheet
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
/**
* Parses and shows the content of one sheet
* using the specified styles and shared-strings tables.
*
* @param styles
* @param strings
* @param sheetInputStream
*/
public void processSheet(
StylesTable styles,
ReadOnlySharedStringsTable strings,
InputStream sheetInputStream,
PrintStream sheetOutputStream)
throws IOException, ParserConfigurationException, SAXException {
InputSource sheetSource = new InputSource(sheetInputStream);
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
SAXParser saxParser = saxFactory.newSAXParser();
XMLReader sheetParser = saxParser.getXMLReader();
ContentHandler handler = new MyXSSFSheetHandler(styles, strings, this.minColumns, sheetOutputStream);
sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource);
}
示例12: process
import org.apache.poi.xssf.model.StylesTable; //导入依赖的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;
}
}
示例13: processSheet
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
/**
* Parses and shows the content of one sheet using the specified styles and
* shared-strings tables.
*
* @param styles
* @param strings
* @param sheetInputStream
*/
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler,
InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException {
DataFormatter formatter = new DataFormatter();
InputSource sheetSource = new InputSource(sheetInputStream);
try {
XMLReader sheetParser = SAXHelper.newXMLReader();
ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource);
} catch (ParserConfigurationException e) {
throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
}
}
示例14: process
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
/**
* 开始解析Excel文档
*
* @throws ReadExcelException
*/
public void process() throws ReadExcelException {
try {
ReadOnlySharedStringsTable strings = new ReadOnlySharedStringsTable(this.xlsxPackage);
XSSFReader xssfReader = new XSSFReader(this.xlsxPackage);
StylesTable styles = xssfReader.getStylesTable();
XSSFReader.SheetIterator iter = (XSSFReader.SheetIterator) xssfReader.getSheetsData();
while (iter.hasNext()) {
//初始化数据
this.initDataPerSheet();
InputStream stream = iter.next();
this.processSheet(styles, strings, this, stream);
stream.close();
}
//解析完后,判断用户是否设置了limit,若设置了执行以下操作
if (this.limit > 0) {
if (!this.datas.isEmpty()) {
if (this.callback != null) {
//若数据不为空且回调函数被设置,则调用回调函数
this.callback.callback(this.currentRowInSheet, this.currentSheetInExcel, this.realRowInSheet,
this.realRowInExcel, this.allSheetInExcel, this.titles, this.columns, this.datas);
}
this.datas.clear();
}
}
} catch (Exception e) {
throw new ReadExcelException(e.getMessage());
}
}
示例15: LoadingSheetXmlHandler
import org.apache.poi.xssf.model.StylesTable; //导入依赖的package包/类
public LoadingSheetXmlHandler( List<String> sst, StylesTable styles,
String sheetname, Map<String, String> ns, boolean lsInMem ) {
super( sst );
this.styles = styles;
namespaces = ns;
// this will automatically convert to a relationship sheet if needed
loadingsheet = LoadingSheetData.nodesheet( sheetname, "", lsInMem );
}