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


Java WSheet类代码示例

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


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

示例1: doProcess

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public void doProcess(WSheet wSheet, Object obj, Field field, Annotation ann,
		AnnotationReader reader, List<NeedPostProcess> needPostProcess)
		throws Exception {

       IterateTables iterateTables = (IterateTables) ann;

       Class<?> fieldType = field.getType();

       // create multi-table objects.
       List<?> value = createTables(wSheet, iterateTables, reader, needPostProcess);
       if (List.class.isAssignableFrom(fieldType)) {
           field.set(obj, value);

       } else if (fieldType.isArray()) {
       	Class<?> type = fieldType.getComponentType();
       	Object array = Array.newInstance(type, value.size());
       	for(int i=0;i<value.size();i++){
       		Array.set(array, i, value.get(i));
       	}
       	field.set(obj, array);

       } else {
           throw new XLSBeansException(
           		"Arguments of '" + field.toString() + "' is invalid.");
       }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:27,代码来源:IterateTablesProcessor.java

示例2: doProcess

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public void doProcess(WSheet wSheet, Object obj, Field field, Annotation ann, AnnotationReader reader,
                         XLSBeansConfig config, List<NeedPostProcess> needPostProcess) throws Exception {

       IterateTables iterateTables = (IterateTables) ann;

       Class<?> fieldType = field.getType();

       // create multi-table objects.
       List<?> value = createTables(wSheet, iterateTables, reader, config, needPostProcess);
       if (List.class.isAssignableFrom(fieldType)) {
           field.set(obj, value);

       } else if (fieldType.isArray()) {
       	Class<?> type = fieldType.getComponentType();
       	Object array = Array.newInstance(type, value.size());
       	for(int i = 0; i < value.size(); i++){
       		Array.set(array, i, value.get(i));
       	}
       	field.set(obj, array);

       } else {
           throw new XLSBeansException("Arguments of '" + field.toString() + "' is invalid.");
       }
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:25,代码来源:IterateTablesProcessor.java

示例3: createTables

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
protected List<?> createTables(WSheet wSheet, IterateTables iterateTables, AnnotationReader reader,
                               XLSBeansConfig config, List<NeedPostProcess> needPostProcess) throws Exception {
    List<Object> resultTableList = new ArrayList<Object>();

    WCell after = null;
    WCell currentCell = null;
    String label = iterateTables.tableLabel();
    currentCell = Utils.getCell(wSheet, label, after, false, !iterateTables.optional(), config);
    while (currentCell != null) {
        // 1 table object instance
        Object tableObj = iterateTables.tableClass().newInstance();

        // process single label.
        processSingleLabelledCell(wSheet, tableObj, currentCell, reader, config, needPostProcess);
        // process horizontal table.
        processMultipleTableCell(wSheet, tableObj, currentCell, reader, iterateTables, config, needPostProcess);

        // TODO process vertical table

        resultTableList.add(tableObj);
        after = currentCell;
        currentCell = Utils.getCell(wSheet, label, after, false, false, config);
    }
    return resultTableList;
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:26,代码来源:IterateTablesProcessor.java

示例4: testGetCellOptionalTrue

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
/**
 * added 2008/12/14
 *
 * If "throwableWhenNotFound" attribute is "true",
 * thrown XLSBeansException by non-existed Cell.
 *
 * @throws Exception
 */
public void testGetCellOptionalTrue() throws Exception {
	WWorkbook w = WorkbookFinder.find(
			UtilsTest.class.getResourceAsStream("example_1.xls"),
			WorkbookFinder.TYPE_JXL);

	WSheet s = w.getSheet("Users2");
	try {
		Utils.getCell(s, "non-existed-label", 0, true, new XLSBeansConfig());
	} catch (XLSBeansException e) {
		assertEquals("Cell 'non-existed-label' doesn't exist.", e.getMessage());
		// SUCCEED
		return;
	}
	fail();
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:24,代码来源:UtilsTest.java

示例5: createTables

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
/**
 * VerticalRecordsへの対応のため、オーバーライドしました。
 * @param sheet シート
 * @param tables IterateTablesアノテーションの定義
 * @param reader アノテーションリーダ
 * @param process プロセッサ
 * @throws Exception 予期しない例外
 */
@Override
protected List<?> createTables(WSheet sheet, IterateTables tables, AnnotationReader reader, List<NeedPostProcess> process)
    throws Exception {

    List<Object> resultTableList = new ArrayList<Object>();
    String label = tables.tableLabel();
    WCell after = null;
    WCell currentCell = Utils.getCell(sheet, label, after, false, !tables.optional());
    while (currentCell != null) {
        // 1 table object instance
        Object obj = tables.tableClass().newInstance();
        // LabeledCellをマッピング
        processSingleLabelledCell(sheet, obj, currentCell, reader, process);
        // HorizontalRecordsをマッピング
        processMultipleTableCell(sheet, obj, currentCell, reader, tables, process);
        // VerticalRecordsをマッピング
        processMultipleTableCellForVertical(sheet, obj, currentCell, reader, tables, process);
        resultTableList.add(obj);
        after = currentCell;
        currentCell = Utils.getCell(sheet, label, after, false, false);
    }
    return resultTableList;
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:32,代码来源:JxIterateTableProcessor.java

示例6: doProcess

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public void doProcess(WSheet wSheet, Object obj,
		Method setter, Annotation ann, AnnotationReader reader,
		List<NeedPostProcess> needPostProcess) throws Exception {

	Cell cell = (Cell)ann;
	Utils.setPosition(cell.column(), cell.row(), obj, Utils.toPropertyName(setter.getName()));

	WCell wCell = wSheet.getCell(cell.column(), cell.row());
	Utils.invokeSetter(setter, obj, wCell.getContents());
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:11,代码来源:CellProcessor.java

示例7: processMapColumns

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
private void processMapColumns(WSheet sheet, List<HeaderInfo> headerInfos,
		int begin, int column, Object record, AnnotationReader reader) throws Exception {

	List<Object> properties = Utils.getMapColumnProperties(record, reader);

	for(Object property : properties){
		MapColumns ann = null;
		if(property instanceof Method){
			ann = reader.getAnnotation(record.getClass(), (Method) property, MapColumns.class);
		} else if(property instanceof Field){
			ann = reader.getAnnotation(record.getClass(), (Field) property, MapColumns.class);
		}

		boolean flag = false;
		Map<String, String> map = new LinkedHashMap<String, String>();
		for(HeaderInfo headerInfo : headerInfos){
			if(headerInfo.getHeaderLabel().equals(ann.previousColumnName())){
				flag = true;
				begin++;
				continue;
			}
			if(flag){
				WCell cell = sheet.getCell(column, begin + headerInfo.getHeaderRange());
				map.put(headerInfo.getHeaderLabel(), cell.getContents());
			}
			begin = begin + headerInfo.getHeaderRange() + 1;
		}

		if(property instanceof Method){
			((Method) property).invoke(record, map);
		} else if(property instanceof Field){
			((Field) property).set(record, map);
		}
	}
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:36,代码来源:VerticalRecordsProcessor.java

示例8: processMapColumns

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
private void processMapColumns(WSheet wSheet, List<HeaderInfo> headerInfos,
		int begin, int row, Object record, AnnotationReader reader) throws Exception {

	List<Object> properties = Utils.getMapColumnProperties(record, reader);

	for(Object property : properties){
		MapColumns ann = null;
		if(property instanceof Method){
			ann = reader.getAnnotation(record.getClass(), (Method) property, MapColumns.class);
		} else if(property instanceof Field){
			ann = reader.getAnnotation(record.getClass(), (Field) property, MapColumns.class);
		}

		boolean flag = false;
		Map<String, String> map = new LinkedHashMap<String, String>();
		for(HeaderInfo headerInfo : headerInfos){
			if(headerInfo.getHeaderLabel().equals(ann.previousColumnName())){
				flag = true;
				begin++;
				continue;
			}
			if(flag){
				WCell cell = wSheet.getCell(begin + headerInfo.getHeaderRange(), row);
				map.put(headerInfo.getHeaderLabel(), cell.getContents());
			}
			begin = begin + headerInfo.getHeaderRange() + 1;
		}

		if(property instanceof Method){
			((Method) property).invoke(record, map);
		} else if(property instanceof Field){
			((Field) property).set(record, map);
		}
	}
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:36,代码来源:HorizontalRecordsProcessor.java

示例9: createTables

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
protected List<?> createTables(WSheet wSheet, IterateTables iterateTables ,
        AnnotationReader reader,  List<NeedPostProcess> needPostProcess) throws Exception {
    List<Object> resultTableList = new ArrayList<Object>();

    WCell after = null;
    WCell currentCell = null;
    String label = iterateTables.tableLabel();
    currentCell = Utils.getCell(wSheet, label, after, false, !iterateTables.optional());
    while (currentCell != null) {
        // 1 table object instance
        Object tableObj = iterateTables.tableClass().newInstance();

        // process single label.
        processSingleLabelledCell(wSheet, tableObj, currentCell, reader,
                needPostProcess);
        // process horizontal table.
        processMultipleTableCell(wSheet, tableObj, currentCell, reader,
                iterateTables, needPostProcess);

        // TODO process vertical table

        resultTableList.add(tableObj);
        after = currentCell;
        currentCell = Utils.getCell(wSheet, label, after, false, false);
    }
    return resultTableList;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:28,代码来源:IterateTablesProcessor.java

示例10: getSheets

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public WSheet[] getSheets() {
	int sheetNum = workbook.getNumberOfSheets();
	WSheet[] retSheets = new WSheet[sheetNum];
	for (int i = 0; i < sheetNum; i++) {
		retSheets[i] = new XssfWSheetImpl(workbook.getSheetAt(i));
	}
	return retSheets;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:9,代码来源:XssfWWorkbookImpl.java

示例11: getSheets

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public WSheet[] getSheets() {
	Sheet[] sheets = workbook.getSheets();
	if (sheets == null) {
		return null;
	}
	WSheet[] retSheets = new WSheet[sheets.length];
	for (int i = 0; i < sheets.length; i++) {
		retSheets[i] = new JxlWSheetImpl(sheets[i]);
	}
	return retSheets;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:12,代码来源:JxlWWorkbookImpl.java

示例12: getCell

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public static WCell getCell(WSheet wSheet, String label, int from, boolean throwableWhenNotFound) throws XLSBeansException {
	int rows = wSheet.getColumns();
	for(int i=0;i<rows;i++){
		WCell[] columns = wSheet.getColumn(i);
		for(int j=from;j<columns.length;j++){
			if(columns[j].getContents().equals(label)){
				return columns[j];
			}
		}
	}
	if (throwableWhenNotFound) {
		throw new XLSBeansException("Cell '" + label + "' doesn't exist.");
	}
	return null;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:16,代码来源:Utils.java

示例13: doProcess

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
public void doProcess(WSheet wSheet, Object obj, Method setter, Annotation ann, AnnotationReader reader,
		XLSBeansConfig config, List<NeedPostProcess> needPostProcess) throws Exception {
	Cell cell = (Cell)ann;
	Utils.setPosition(cell.column(), cell.row(), obj, Utils.toPropertyName(setter.getName()));

	WCell wCell = wSheet.getCell(cell.column(), cell.row());
	Utils.invokeSetter(setter, obj, wCell.getContents(), config);
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:9,代码来源:CellProcessor.java

示例14: processMapColumns

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
private void processMapColumns(WSheet sheet, List<HeaderInfo> headerInfos,
		int begin, int column, Object record, AnnotationReader reader, XLSBeansConfig config) throws Exception {

	List<Object> properties = Utils.getMapColumnProperties(record, reader);

	for(Object property : properties){
		MapColumns ann = null;
		if(property instanceof Method){
			ann = reader.getAnnotation(record.getClass(), (Method) property, MapColumns.class);
		} else if(property instanceof Field){
			ann = reader.getAnnotation(record.getClass(), (Field) property, MapColumns.class);
		}

		boolean flag = false;
		Map<String, String> map = new LinkedHashMap<String, String>();
		for(HeaderInfo headerInfo : headerInfos){
               if(Utils.matches(headerInfo.getHeaderLabel(), ann.previousColumnName(), config)){
				flag = true;
				begin++;
				continue;
			}
			if(flag){
				WCell cell = sheet.getCell(column, begin + headerInfo.getHeaderRange());
				map.put(headerInfo.getHeaderLabel(), cell.getContents());
			}
			begin = begin + headerInfo.getHeaderRange() + 1;
		}

		if(property instanceof Method){
			((Method) property).invoke(record, map);
		} else if(property instanceof Field){
			((Field) property).set(record, map);
		}
	}
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:36,代码来源:VerticalRecordsProcessor.java

示例15: processMapColumns

import net.java.amateras.xlsbeans.xssfconverter.WSheet; //导入依赖的package包/类
private void processMapColumns(WSheet wSheet, List<HeaderInfo> headerInfos,
		int begin, int row, Object record, AnnotationReader reader, XLSBeansConfig config) throws Exception {

	List<Object> properties = Utils.getMapColumnProperties(record, reader);

	for(Object property : properties){
		MapColumns ann = null;
		if(property instanceof Method){
			ann = reader.getAnnotation(record.getClass(), (Method) property, MapColumns.class);
		} else if(property instanceof Field){
			ann = reader.getAnnotation(record.getClass(), (Field) property, MapColumns.class);
		}

		boolean flag = false;
		Map<String, String> map = new LinkedHashMap<String, String>();
		for(HeaderInfo headerInfo : headerInfos){
               if(Utils.matches(headerInfo.getHeaderLabel(), ann.previousColumnName(), config)){
                   flag = true;
                   begin++;
                   continue;
               }
			if(flag){
				WCell cell = wSheet.getCell(begin + headerInfo.getHeaderRange(), row);
				map.put(headerInfo.getHeaderLabel(), cell.getContents());
			}
			begin = begin + headerInfo.getHeaderRange() + 1;
		}

		if(property instanceof Method){
			((Method) property).invoke(record, map);
		} else if(property instanceof Field){
			((Field) property).set(record, map);
		}
	}
}
 
开发者ID:takezoe,项目名称:xlsbeans,代码行数:36,代码来源:HorizontalRecordsProcessor.java


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