當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFRow.setHeight方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFRow.setHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFRow.setHeight方法的具體用法?Java HSSFRow.setHeight怎麽用?Java HSSFRow.setHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFRow的用法示例。


在下文中一共展示了HSSFRow.setHeight方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeCondtions

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
/**
 * 表頭條件
 * @param sheet
 * @param t
 * @param cellCount
 * @return
 */
void writeCondtions(HSSFSheet sheet){
	T t = getConditions();
	if (t!=null) {
		HSSFRow row = sheet.createRow(getRowNumber());
		row.setHeight((short) 500);
		CellRangeAddress cra = new CellRangeAddress(getRowNumber(), getRowNumber(), 0, getColumnJson().size());
		sheet.addMergedRegion(cra);
		HSSFCell cell = row.createCell(0);
		HSSFCellStyle style = cell.getCellStyle();
		style.setAlignment(HorizontalAlignment.CENTER);
		style.setVerticalAlignment(VerticalAlignment.CENTER);
		style.setWrapText(true);
		cell.setCellStyle(style);
		setCellValue(cell, formatCondition(t));
		addRowNumber();
	}
}
 
開發者ID:leiyong0326,項目名稱:phone,代碼行數:25,代碼來源:ExcelExportSuper.java

示例2: copyRow

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
/**
 * @param srcSheet the sheet to copy.
 * @param destSheet the sheet to create.
 * @param srcRow the row to copy.
 * @param destRow the row to create.
 * @param styleMap -
 */
public static void copyRow(HSSFSheet srcSheet, HSSFSheet destSheet, HSSFRow srcRow, HSSFRow destRow, Map<Integer, HSSFCellStyle> styleMap) {
    // manage a list of merged zone in order to not insert two times a merged zone  
    Set<CellRangeAddressWrapper> mergedRegions = new TreeSet<CellRangeAddressWrapper>();
    destRow.setHeight(srcRow.getHeight());
    // pour chaque row  
    for (int j = srcRow.getFirstCellNum(); j <= srcRow.getLastCellNum(); j++) {
        if(j<0){
        }else{
        HSSFCell oldCell = srcRow.getCell(j);   // ancienne cell  
        HSSFCell newCell = destRow.getCell(j);  // new cell   
        if (oldCell != null) {
            if (newCell == null) {
                newCell = destRow.createCell(j);
            }
            // copy chaque cell  
            copyCell(oldCell, newCell, styleMap);
                  // copy les informations de fusion entre les cellules  
            //System.out.println("row num: " + srcRow.getRowNum() + " , col: " + (short)oldCell.getColumnIndex());  
            CellRangeAddress mergedRegion = getMergedRegion(srcSheet, srcRow.getRowNum(), (short) oldCell.getColumnIndex());

            if (mergedRegion != null) {
                //System.out.println("Selected merged region: " + mergedRegion.toString());  
                CellRangeAddress newMergedRegion = new CellRangeAddress(mergedRegion.getFirstRow(), mergedRegion.getLastRow(), mergedRegion.getFirstColumn(), mergedRegion.getLastColumn());
                //System.out.println("New merged region: " + newMergedRegion.toString());  
                CellRangeAddressWrapper wrapper = new CellRangeAddressWrapper(newMergedRegion);
                if (isNewMergedRegion(wrapper, mergedRegions)) {
                    mergedRegions.add(wrapper);
                    destSheet.addMergedRegion(wrapper.range);
                }
            }
        }
    }
    }

}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:43,代碼來源:Util.java

示例3: copyRow

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
public static void copyRow(final HSSFSheet oldSheet, final HSSFSheet newSheet, final int oldRowNum, final int newRowNum) {
    final HSSFRow oldRow = oldSheet.getRow(oldRowNum);

    final HSSFRow newRow = newSheet.createRow(newRowNum);

    if (oldRow == null) {
        return;
    }

    newRow.setHeight(oldRow.getHeight());

    if (oldRow.getFirstCellNum() == -1) {
        return;
    }

    for (int colNum = oldRow.getFirstCellNum(); colNum <= oldRow.getLastCellNum(); colNum++) {
        final HSSFCell oldCell = oldRow.getCell(colNum);
        final HSSFCell newCell = newRow.createCell(colNum);

        if (oldCell != null) {
            final HSSFCellStyle style = oldCell.getCellStyle();
            newCell.setCellStyle(style);

            final int cellType = oldCell.getCellType();
            newCell.setCellType(cellType);

            if (cellType == Cell.CELL_TYPE_BOOLEAN) {
                newCell.setCellValue(oldCell.getBooleanCellValue());

            } else if (cellType == Cell.CELL_TYPE_FORMULA) {
                newCell.setCellFormula(oldCell.getCellFormula());

            } else if (cellType == Cell.CELL_TYPE_NUMERIC) {
                newCell.setCellValue(oldCell.getNumericCellValue());

            } else if (cellType == Cell.CELL_TYPE_STRING) {
                newCell.setCellValue(oldCell.getRichStringCellValue());
            }
        }
    }

    POIUtils.copyMergedRegion(newSheet, getMergedRegionList(oldSheet, oldRowNum), newRowNum);
}
 
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:44,代碼來源:POIUtils.java

示例4: downloadXLSFileBase

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
public FileTransfer downloadXLSFileBase(List<String[]> list,
	String filename, String name) throws Exception {
if (list == null) {
	list = new ArrayList<String[]>();
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();

HSSFCellStyle cs = wb.createCellStyle();
cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cs.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

int columnCount = list.get(0).length;
sheet.setColumnWidth((short) 0, (short) 100);
sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
		(short) columnCount));
for (int i = 1; i <= columnCount; i++) {
	sheet.setColumnWidth((short) i, (short) 4000);
}
// 表名
HSSFRow row1 = sheet.createRow(0);
HSSFCell cell = row1.createCell((short) 0);
// cell.setEncoding((short) 0);
cell.setCellValue(name);
cell.setCellStyle(cs);
row1.setHeight((short) 800);

HSSFRow rows = null;
for (int i = 0; i < list.size(); i++) {
	rows = sheet.createRow(i + 1);
	String cellDate[] = list.get(i);
	HSSFCell cells = null;
	for (int j = 0; j < cellDate.length; j++) {
		cells = rows.createCell((short) (j + 1));
		// cells.setEncoding((short) j);
		cells.setCellValue(cellDate[j]);
		cells.setCellStyle(cs);
	}
	if (i == 0) {
		rows.setHeight((short) 600);// 標題行寬
	}
}
wb.write(buffer);
return new FileTransfer(filename, "application/x-xls", buffer
		.toByteArray());
}
 
開發者ID:wufeisoft,項目名稱:ryf_mms2,代碼行數:52,代碼來源:DownloadFile.java

示例5: downloadXLSFileBase

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
private FileTransfer downloadXLSFileBase(List<String[]> list,
		String filename, String name) throws Exception {
	if (list == null) {
		list = new ArrayList<String[]>();
	}
	ByteArrayOutputStream buffer = new ByteArrayOutputStream();
	HSSFWorkbook wb = new HSSFWorkbook();
	HSSFSheet sheet = wb.createSheet();

	HSSFCellStyle cs = wb.createCellStyle();
	cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
	cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
	cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	cs.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);

	int columnCount = list.get(0).length;
	sheet.setColumnWidth((short) 0, (short) 100);
	sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
			(short) columnCount));
	for (int i = 1; i <= columnCount; i++) {
		sheet.setColumnWidth((short) i, (short) 4000);
	}
	// 表名
	HSSFRow row1 = sheet.createRow(0);
	HSSFCell cell = row1.createCell((short) 0);
	// cell.setEncoding((short) 0);
	cell.setCellValue(name);
	cell.setCellStyle(cs);
	row1.setHeight((short) 800);

	HSSFRow rows = null;
	for (int i = 0; i < list.size(); i++) {
		rows = sheet.createRow(i + 1);
		String cellDate[] = list.get(i);
		HSSFCell cells = null;
		for (int j = 0; j < cellDate.length; j++) {
			cells = rows.createCell((short) (j + 1));
			// cells.setEncoding((short) j);
			cells.setCellValue(cellDate[j]);
			cells.setCellStyle(cs);
		}
		if (i == 0) {
			rows.setHeight((short) 600);// 標題行寬
		}
	}
	wb.write(buffer);
	return new FileTransfer(filename, "application/x-xls", buffer
			.toByteArray());
}
 
開發者ID:wufeisoft,項目名稱:ryf_mms2,代碼行數:52,代碼來源:DownloadFileService.java

示例6: exportMotionExcel

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
/**
 * 為退款經辦下載表
 * 
 * @param outfile
 * @param list
 * @param name
 *            表名
 * @param s為每一格的寬度
 * @throws IOException
 */
public FileTransfer exportMotionExcel(List<String[]> list, String filename,
		String name, String[] s) throws Exception {

	ByteArrayOutputStream buffer = new ByteArrayOutputStream();
	HSSFWorkbook wb = new HSSFWorkbook();
	HSSFSheet sheet = wb.createSheet();
	HSSFCellStyle cs = wb.createCellStyle();
	// 設置表頭的格式
	HSSFCellStyle cs1 = wb.createCellStyle();
	HSSFFont f1 = wb.createFont();
	f1.setFontHeightInPoints((short) 20);// 字體大小
	cs1.setFont(f1);
	cs1.setAlignment(HSSFCellStyle.ALIGN_CENTER);

	// 設置表中的格�?
	cs.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	cs.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	cs.setBorderRight(HSSFCellStyle.BORDER_THIN);
	cs.setBorderTop(HSSFCellStyle.BORDER_THIN);
	cs.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	cs.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
	cs.setWrapText(true);// 自動換行
	// 將頁麵設�為橫向打印模�?
	HSSFPrintSetup hps = sheet.getPrintSetup();
	hps.setLandscape(true); // 將頁麵設置為橫向打印模式
	hps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);// 為A4紙的大小

	int columnCount = list.get(0).length;
	// 表頭那一列的的寬�?
	sheet.setColumnWidth((short) 0, (short) 10000);
	// 合並單元�?
	// sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
	// (short) (columnCount-1)));
	// 根據String[] s來設定每一格的寬度
	for (int i = 0; i < columnCount; i++) {
		sheet.setColumnWidth((short) i, (Short.parseShort(s[i])));
	}
	// 表名
	HSSFRow row1 = sheet.createRow(0);
	HSSFCell cell = row1.createCell(0);
	cell.setCellValue(name);
	cell.setCellStyle(cs1);
	row1.setHeight((short) 800);
	sheet.addMergedRegion(new Region((short) 0, (short) 0, (short) 0,
			(short) (columnCount - 1)));

	HSSFRow rows = null;
	for (int i = 0; i < list.size(); i++) {
		rows = sheet.createRow(i + 1);
		String cellDate[] = list.get(i);
		HSSFCell cells = null;
		for (int j = 0; j < cellDate.length; j++) {
			cells = rows.createCell((short) (j));
			cells.setCellValue(cellDate[j]);
			cells.setCellStyle(cs);
		}
		if (i == 0) {
			rows.setHeight((short) 600);// 標題行寬�?
		}
	}
	wb.write(buffer);
	return new FileTransfer(filename, "application/x-xls", buffer
			.toByteArray());
}
 
開發者ID:wufeisoft,項目名稱:ryf_mms2,代碼行數:75,代碼來源:DownloadFileService.java

示例7: copyRow

import org.apache.poi.hssf.usermodel.HSSFRow; //導入方法依賴的package包/類
public static void copyRow(HSSFSheet oldSheet, HSSFSheet newSheet,
		int oldRowNum, int newRowNum) {
	HSSFRow oldRow = oldSheet.getRow(oldRowNum);

	HSSFRow newRow = newSheet.createRow(newRowNum);

	if (oldRow == null) {
		return;
	}

	newRow.setHeight(oldRow.getHeight());

	if (oldRow.getFirstCellNum() == -1) {
		return;
	}

	for (int colNum = oldRow.getFirstCellNum(); colNum <= oldRow
			.getLastCellNum(); colNum++) {
		HSSFCell oldCell = oldRow.getCell(colNum);
		HSSFCell newCell = newRow.createCell(colNum);

		if (oldCell != null) {
			HSSFCellStyle style = oldCell.getCellStyle();
			newCell.setCellStyle(style);

			int cellType = oldCell.getCellType();
			newCell.setCellType(cellType);

			if (cellType == HSSFCell.CELL_TYPE_BOOLEAN) {
				newCell.setCellValue(oldCell.getBooleanCellValue());

			} else if (cellType == HSSFCell.CELL_TYPE_FORMULA) {
				newCell.setCellFormula(oldCell.getCellFormula());

			} else if (cellType == HSSFCell.CELL_TYPE_NUMERIC) {
				newCell.setCellValue(oldCell.getNumericCellValue());

			} else if (cellType == HSSFCell.CELL_TYPE_STRING) {
				newCell.setCellValue(oldCell.getRichStringCellValue());
			}
		}
	}

	POIUtils.copyMergedRegion(newSheet,
			getMergedRegionList(oldSheet, oldRowNum), newRowNum);
}
 
開發者ID:kozake,項目名稱:ermaster-k,代碼行數:47,代碼來源:POIUtils.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFRow.setHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。