Java Code Examples for org.apache.poi.xwpf.usermodel.XWPFTableRow#setHeight()

The following examples show how to use org.apache.poi.xwpf.usermodel.XWPFTableRow#setHeight() . 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: ExcelEntityParse.java    From autopoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, XWPFTable table) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row;
	if (table.getRow(index) == null) {
		row = table.createRow();
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = table.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		if (entity.getType() == 1) {
			setCellValue(row, value, cellNum++);
		}
	}
}
 
Example 2
Source File: ExcelEntityParse.java    From jeasypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj, List<ExcelExportEntity> excelParams, XWPFTable table) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row;
	if (table.getRow(index) == null) {
		row = table.createRow();
		row.setHeight(getRowHeight(excelParams));
	} else {
		row = table.getRow(index);
	}
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		Object value = getCellValue(entity, obj);
		if (entity.getType() == 1) {
			setCellValue(row, value, cellNum++);
		}
	}
}
 
Example 3
Source File: ExcelEntityParse.java    From easypoi with Apache License 2.0 6 votes vote down vote up
/**
 * 创建List之后的各个Cells
 * 
 * @param styles
 */
public void createListCells(int index, int cellNum, Object obj,
                            List<ExcelExportEntity> excelParams, XWPFTable table)
                                                                                 throws Exception {
    ExcelExportEntity entity;
    XWPFTableRow row;
    if (table.getRow(index) == null) {
        row = table.createRow();
        row.setHeight(getRowHeight(excelParams));
    } else {
        row = table.getRow(index);
    }
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        Object value = getCellValue(entity, obj);
        if (entity.getType() == 1) {
            setCellValue(row, value, cellNum++);
        }
    }
}
 
Example 4
Source File: ExcelEntityParse.java    From autopoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams, XWPFTable table, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row = table.createRow();
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			Collection<?> list = (Collection<?>) entity.getMethod().invoke(t, new Object[] {});
			int listC = 0;
			for (Object obj : list) {
				createListCells(index + listC, cellNum, obj, entity.getList(), table);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			if (entity.getType() == 1) {
				setCellValue(row, value, cellNum++);
			}
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
			cellNum++;
		}
	}
	return maxHeight;
}
 
Example 5
Source File: ExcelEntityParse.java    From jeasypoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams, XWPFTable table, short rowHeight) throws Exception {
	ExcelExportEntity entity;
	XWPFTableRow row = table.createRow();
	row.setHeight(rowHeight);
	int maxHeight = 1, cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			Collection<?> list = (Collection<?>) entity.getMethod().invoke(t, new Object[] {});
			int listC = 0;
			for (Object obj : list) {
				createListCells(index + listC, cellNum, obj, entity.getList(), table);
				listC++;
			}
			cellNum += entity.getList().size();
			if (list != null && list.size() > maxHeight) {
				maxHeight = list.size();
			}
		} else {
			Object value = getCellValue(entity, t);
			if (entity.getType() == 1) {
				setCellValue(row, value, cellNum++);
			}
		}
	}
	// 合并需要合并的单元格
	cellNum = 0;
	for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
		entity = excelParams.get(k);
		if (entity.getList() != null) {
			cellNum += entity.getList().size();
		} else if (entity.isNeedMerge()) {
			table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
			cellNum++;
		}
	}
	return maxHeight;
}
 
Example 6
Source File: ExcelEntityParse.java    From easypoi with Apache License 2.0 5 votes vote down vote up
private int createCells(int index, Object t, List<ExcelExportEntity> excelParams,
                        XWPFTable table, short rowHeight) throws Exception {
    ExcelExportEntity entity;
    XWPFTableRow row = table.createRow();
    row.setHeight(rowHeight);
    int maxHeight = 1, cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            Collection<?> list = (Collection<?>) entity.getMethod().invoke(t, new Object[] {});
            int listC = 0;
            for (Object obj : list) {
                createListCells(index + listC, cellNum, obj, entity.getList(), table);
                listC++;
            }
            cellNum += entity.getList().size();
            if (list != null && list.size() > maxHeight) {
                maxHeight = list.size();
            }
        } else {
            Object value = getCellValue(entity, t);
            if (entity.getType() == 1) {
                setCellValue(row, value, cellNum++);
            }
        }
    }
    // 合并需要合并的单元格
    cellNum = 0;
    for (int k = 0, paramSize = excelParams.size(); k < paramSize; k++) {
        entity = excelParams.get(k);
        if (entity.getList() != null) {
            cellNum += entity.getList().size();
        } else if (entity.isNeedMerge()) {
            table.setCellMargins(index, index + maxHeight - 1, cellNum, cellNum);
            cellNum++;
        }
    }
    return maxHeight;
}