当前位置: 首页>>代码示例>>Java>>正文


Java SharedStringsTable类代码示例

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


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

示例1: process

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/**
 * 遍历工作簿中所有的电子表格
 * 
 * @param filename
 * @throws Exception
 */
public void process(InputStream stream) throws Exception {
	OPCPackage pkg = OPCPackage.open(stream);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();
	XMLReader parser = fetchSheetParser(sst);
	Iterator<InputStream> sheets = r.getSheetsData();
	while (sheets.hasNext()) {
		curRow = 0;
		sheetIndex++;
		InputStream sheet = sheets.next();
		InputSource sheetSource = new InputSource(sheet);
		parser.parse(sheetSource);
		sheet.close();
	}
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:22,代码来源:Excel2007Reader.java

示例2: process

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/**
 * 遍历工作簿中所有的电子表格
 * 
 * @param filename string
 * @throws Exception  if an error occurred
 */
public void process(String filename) throws Exception {
	OPCPackage pkg = OPCPackage.open(filename);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();
	XMLReader parser = fetchSheetParser(sst);
	Iterator<InputStream> sheets = r.getSheetsData();
	while (sheets.hasNext()) {
		curRow = 0;
		sheetIndex++;
		InputStream sheet = sheets.next();
		InputSource sheetSource = new InputSource(sheet);
		parser.parse(sheetSource);
		sheet.close();
	}
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:22,代码来源:Excel2007Reader.java

示例3: process

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/**
 * 遍历工作簿中所有的电子表格
 * 
 * @param filename
 * @throws Exception
 */
public void process(String filename) throws Exception {
	OPCPackage pkg = OPCPackage.open(filename);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();
	XMLReader parser = fetchSheetParser(sst);
	Iterator<InputStream> sheets = r.getSheetsData();
	while (sheets.hasNext()) {
		curRow = 0;
		sheetIndex++;
		InputStream sheet = sheets.next();
		InputSource sheetSource = new InputSource(sheet);
		parser.parse(sheetSource);
		sheet.close();
	}
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:22,代码来源:Excel2007Reader.java

示例4: processAll

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的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

示例5: processBySheet

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的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

示例6: fetchSheetParser

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
public XMLReader fetchSheetParser(SharedStringsTable sst, DataTable dataTable, PrintWriter tempOut) throws SAXException {
    // An attempt to use org.apache.xerces.parsers.SAXParser resulted 
    // in some weird conflict in the app; the default XMLReader obtained 
    // from the XMLReaderFactory (from xml-apis.jar) appears to be working
    // just fine. however, 
    // TODO: verify why the app gets built with xml-apis-1.0.b2.jar; it's 
    // an old version - 1.4 seems to be the current release, and 2.0.2
    // (a new development?) appears to be available. We don't specifically
    // request this 1.0.* version, so another package must have it defined
    // as a dependency. We need to verify our dependencies, we most likely 
    // have some hard-coded versions in our pom.xml that are both old and 
    // unnecessary.
    // -- L.A. 4.0 alpha 1
 
    XMLReader xReader = XMLReaderFactory.createXMLReader();
    dbglog.fine("creating new SheetHandler;");
    ContentHandler handler = new SheetHandler(sst, dataTable, tempOut);
    xReader.setContentHandler(handler);
    return xReader;
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:21,代码来源:XLSXFileReader.java

示例7: readExcel

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
private <T> List<T> readExcel(OPCPackage opcPackage, Class<?> pojoClass, ImportParams params,
                              ISaxRowRead rowRead, IExcelReadRowHanlder hanlder) {
    try {
        XSSFReader xssfReader = new XSSFReader(opcPackage);
        SharedStringsTable sst = xssfReader.getSharedStringsTable();
        if (rowRead == null) {
            rowRead = new SaxRowRead(pojoClass, params, hanlder);
        }
        XMLReader parser = fetchSheetParser(sst, rowRead);
        Iterator<InputStream> sheets = xssfReader.getSheetsData();
        int sheetIndex = 0;
        while (sheets.hasNext() && sheetIndex < params.getSheetNum()) {
            sheetIndex++;
            InputStream sheet = sheets.next();
            InputSource sheetSource = new InputSource(sheet);
            parser.parse(sheetSource);
            sheet.close();
        }
        return rowRead.getList();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw new ExcelImportException("SAX导入数据失败");
    }
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:25,代码来源:SaxReadExcel.java

示例8: processOneSheet

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
public void processOneSheet(String filename, int sheetId) throws Exception {
	OPCPackage pkg = OPCPackage.open(filename);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();

	XMLReader parser = fetchSheetParser(sst);

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

示例9: process

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/**
 * 遍历 excel 文件
 */
public void process(String filename) throws Exception {
	OPCPackage pkg = OPCPackage.open(filename);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();

	XMLReader parser = fetchSheetParser(sst);

	Iterator<InputStream> sheets = r.getSheetsData();
	while (sheets.hasNext()) {
		curRow = 0;
		sheetIndex++;
		InputStream sheet = sheets.next();
		InputSource sheetSource = new InputSource(sheet);
		parser.parse(sheetSource);
		sheet.close();
	}
	pkg.close();
}
 
开发者ID:RayleighChen,项目名称:Improve,代码行数:22,代码来源:XxlsAbstract.java

示例10: parseCSVFromSheet

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的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

示例11: loadSheets

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的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)));
  }
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:22,代码来源:StreamingWorkbookReader.java

示例12: readOneSheet

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/** 
 * 读取第一个工作簿的入口方法 
 * @param path 
 */  
public List<?> readOneSheet(InputStream input,String excelType) throws Exception {  
    OPCPackage pkg = OPCPackage.open(input);    
    XSSFReader r = new XSSFReader(pkg);  
    SharedStringsTable sst = r.getSharedStringsTable();  
    
    if(excelType.equals(Constant.ENITY_TYPE_ROLEPERSIONAL)){
    	
    	lists = new ArrayList<AuthRoleUser>();
    }
    
    XMLReader parser = fetchSheetParser(sst);  
          
    InputStream sheet = r.getSheet("rId1");  
  
    InputSource sheetSource = new InputSource(sheet);  
    parser.parse(sheetSource);  
    
    
    if(excelType.equals(Constant.ENITY_TYPE_ROLEPERSIONAL)){

    	return lists;
    }
    sheet.close();        
    return lists;
}
 
开发者ID:lz84,项目名称:bachelor,代码行数:30,代码来源:ParseBigDatasExcel.java

示例13: process

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/** 
 * 读取所有工作簿的入口方法 
 * @param path 
 * @throws Exception 
 */  
public void process(String path) throws Exception {  
    OPCPackage pkg = OPCPackage.open(path);  
    XSSFReader r = new XSSFReader(pkg);  
    SharedStringsTable sst = r.getSharedStringsTable();  
  
    XMLReader parser = fetchSheetParser(sst);  
  
    Iterator<InputStream> sheets = r.getSheetsData();  
    while (sheets.hasNext()) {  
        curRow = 0;  
        sheetIndex++;  
        InputStream sheet = sheets.next();  
        InputSource sheetSource = new InputSource(sheet);  
        parser.parse(sheetSource);  
        sheet.close();  
    }  
}
 
开发者ID:lz84,项目名称:bachelor,代码行数:23,代码来源:ParseBigDatasExcel.java

示例14: mockSharedStringsTable

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
private SharedStringsTable mockSharedStringsTable( String... strings ) {
  SharedStringsTable sst = new SharedStringsTable();
  for ( String str : strings ) {
    CTRst st = CTRst.Factory.newInstance();
    st.setT( str );
    sst.addEntry( st );
  }
  return sst;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:10,代码来源:StaxPoiSheetTest.java

示例15: processOneSheet

import org.apache.poi.xssf.model.SharedStringsTable; //导入依赖的package包/类
/**
 * 只遍历一个电子表格,其中sheetId为要遍历的sheet索引,从1开始,1-3
 * 
 * @param filename
 * @param sheetId
 * @throws Exception
 */
public void processOneSheet(String filename, int sheetId) throws Exception {
	OPCPackage pkg = OPCPackage.open(filename);
	XSSFReader r = new XSSFReader(pkg);
	SharedStringsTable sst = r.getSharedStringsTable();
	XMLReader parser = fetchSheetParser(sst);

	// 根据 rId# 或 rSheet# 查找sheet
	InputStream sheet2 = r.getSheet("rId" + sheetId);
	sheetIndex++;
	InputSource sheetSource = new InputSource(sheet2);
	parser.parse(sheetSource);
	sheet2.close();
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:21,代码来源:Excel2007Reader.java


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