org.jeecgframework.poi.excel.entity.enmus.ExcelType Java Examples

The following examples show how to use org.jeecgframework.poi.excel.entity.enmus.ExcelType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExcelExportOfTemplateUtil.java    From autopoi with Apache License 2.0 5 votes vote down vote up
/**
 * 往Sheet 填充正常数据,根据表头信息 使用导入的部分逻辑,坐对象映射
 * 
 * @param teplateParams
 * @param pojoClass
 * @param dataSet
 * @param workbook
 */
private void addDataToSheet(Class<?> pojoClass, Collection<?> dataSet, Sheet sheet, Workbook workbook) throws Exception {

	if (workbook instanceof XSSFWorkbook) {
		super.type = ExcelType.XSSF;
	}
	// 获取表头数据
	Map<String, Integer> titlemap = getTitleMap(sheet);
	Drawing patriarch = sheet.createDrawingPatriarch();
	// 得到所有字段
	Field[] fileds = PoiPublicUtil.getClassFields(pojoClass);
	ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class);
	String targetId = null;
	if (etarget != null) {
		targetId = etarget.value();
	}
	// 获取实体对象的导出数据
	List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>();
	getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null);
	// 根据表头进行筛选排序
	sortAndFilterExportField(excelParams, titlemap);
	short rowHeight = getRowHeight(excelParams);
	int index = teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(), titleHeight = index;
	// 下移数据,模拟插入
	sheet.shiftRows(teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(), sheet.getLastRowNum(), getShiftRows(dataSet, excelParams), true, true);
	if (excelParams.size() == 0) {
		return;
	}
	Iterator<?> its = dataSet.iterator();
	while (its.hasNext()) {
		Object t = its.next();
		index += createCells(patriarch, index, t, excelParams, sheet, workbook, rowHeight);
	}
	// 合并同类项
	mergeCells(sheet, excelParams, titleHeight);
}
 
Example #2
Source File: ExcelExportOfTemplateUtil.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 往Sheet 填充正常数据,根据表头信息 使用导入的部分逻辑,坐对象映射
 * 
 * @param teplateParams
 * @param pojoClass
 * @param dataSet
 * @param workbook
 */
private void addDataToSheet(Class<?> pojoClass, Collection<?> dataSet, Sheet sheet, Workbook workbook) throws Exception {

	if (workbook instanceof XSSFWorkbook) {
		super.type = ExcelType.XSSF;
	}
	// 获取表头数据
	Map<String, Integer> titlemap = getTitleMap(sheet);
	Drawing patriarch = sheet.createDrawingPatriarch();
	// 得到所有字段
	Field[] fileds = PoiPublicUtil.getClassFields(pojoClass);
	ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class);
	String targetId = null;
	if (etarget != null) {
		targetId = etarget.value();
	}
	// 获取实体对象的导出数据
	List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>();
	getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null);
	// 根据表头进行筛选排序
	sortAndFilterExportField(excelParams, titlemap);
	short rowHeight = getRowHeight(excelParams);
	int index = teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(), titleHeight = index;
	// 下移数据,模拟插入
	sheet.shiftRows(teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(), sheet.getLastRowNum(), getShiftRows(dataSet, excelParams), true, true);
	if (excelParams.size() == 0) {
		return;
	}
	Iterator<?> its = dataSet.iterator();
	while (its.hasNext()) {
		Object t = its.next();
		index += createCells(patriarch, index, t, excelParams, sheet, workbook, rowHeight);
	}
	// 合并同类项
	mergeCells(sheet, excelParams, titleHeight);
}
 
Example #3
Source File: ExcelExportOfTemplateUtil.java    From easypoi with Apache License 2.0 5 votes vote down vote up
/**
 * 往Sheet 填充正常数据,根据表头信息 使用导入的部分逻辑,坐对象映射
 * 
 * @param teplateParams
 * @param pojoClass
 * @param dataSet
 * @param workbook
 */
private void addDataToSheet(Class<?> pojoClass, Collection<?> dataSet, Sheet sheet,
                            Workbook workbook) throws Exception {

    if (workbook instanceof XSSFWorkbook) {
        super.type = ExcelType.XSSF;
    }
    // 获取表头数据
    Map<String, Integer> titlemap = getTitleMap(sheet);
    Drawing patriarch = sheet.createDrawingPatriarch();
    // 得到所有字段
    Field[] fileds = PoiPublicUtil.getClassFields(pojoClass);
    ExcelTarget etarget = pojoClass.getAnnotation(ExcelTarget.class);
    String targetId = null;
    if (etarget != null) {
        targetId = etarget.value();
    }
    // 获取实体对象的导出数据
    List<ExcelExportEntity> excelParams = new ArrayList<ExcelExportEntity>();
    getAllExcelField(null, targetId, fileds, excelParams, pojoClass, null);
    // 根据表头进行筛选排序
    sortAndFilterExportField(excelParams, titlemap);
    short rowHeight = getRowHeight(excelParams);
    int index = teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(), titleHeight = index;
    //下移数据,模拟插入
    sheet.shiftRows(teplateParams.getHeadingRows() + teplateParams.getHeadingStartRow(),
        sheet.getLastRowNum(), getShiftRows(dataSet, excelParams), true, true);
    if (excelParams.size() == 0) {
        return;
    }
    Iterator<?> its = dataSet.iterator();
    while (its.hasNext()) {
        Object t = its.next();
        index += createCells(patriarch, index, t, excelParams, sheet, workbook, rowHeight);
    }
    // 合并同类项
    mergeCells(sheet, excelParams, titleHeight);
}
 
Example #4
Source File: ExportParams.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExportParams(String title, String sheetName, ExcelType type) {
	this.title = title;
	this.sheetName = sheetName;
	this.type = type;
}
 
Example #5
Source File: ExportParams.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public ExcelType getType() {
	return type;
}
 
Example #6
Source File: ExportParams.java    From autopoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelType type) {
	this.type = type;
}
 
Example #7
Source File: ExportParams.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExportParams(String title, String sheetName, ExcelType type) {
	this.title = title;
	this.sheetName = sheetName;
	this.type = type;
}
 
Example #8
Source File: ExportParams.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public ExcelType getType() {
	return type;
}
 
Example #9
Source File: ExportParams.java    From jeasypoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelType type) {
	this.type = type;
}
 
Example #10
Source File: ExportParams.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExportParams(String title, String sheetName, ExcelType type) {
    this.title = title;
    this.sheetName = sheetName;
    this.type = type;
}
 
Example #11
Source File: ExportParams.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public ExcelType getType() {
    return type;
}
 
Example #12
Source File: ExportParams.java    From easypoi with Apache License 2.0 4 votes vote down vote up
public void setType(ExcelType type) {
    this.type = type;
}