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


Java HSSFSheet.getPrintSetup方法代碼示例

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


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

示例1: createSheet

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private HSSFSheet createSheet ( final List<Event> events, final HSSFWorkbook workbook, final List<Field> columns )
{
    final HSSFSheet sheet = workbook.createSheet ( Messages.ExportImpl_ExcelSheet_Name );

    final HSSFHeader header = sheet.getHeader ();
    header.setLeft ( Messages.ExportImpl_ExcelSheet_Header );
    header.setRight ( HeaderFooter.date () + " " + HeaderFooter.time () );//$NON-NLS-1$

    final HSSFFooter footer = sheet.getFooter ();
    footer.setLeft ( String.format ( Messages.ExportImpl_ExcelSheet_Footer_1, events.size () ) );

    footer.setRight ( Messages.ExportImpl_ExcelSheet_Footer_2 + HeaderFooter.page () + Messages.ExportImpl_ExcelSheet_Footer_3 + HeaderFooter.numPages () );

    makeHeader ( columns, sheet );

    final HSSFPrintSetup printSetup = sheet.getPrintSetup ();
    printSetup.setLandscape ( true );
    printSetup.setFitWidth ( (short)1 );
    printSetup.setFitHeight ( (short)0 );
    printSetup.setPaperSize ( PrintSetup.A4_PAPERSIZE );

    sheet.setAutoFilter ( new CellRangeAddress ( 0, 0, 0, columns.size () - 1 ) );
    sheet.createFreezePane ( 0, 1 );
    sheet.setFitToPage ( true );
    sheet.setAutobreaks ( true );

    printSetup.setFooterMargin ( 0.25 );

    sheet.setMargin ( Sheet.LeftMargin, 0.25 );
    sheet.setMargin ( Sheet.RightMargin, 0.25 );
    sheet.setMargin ( Sheet.TopMargin, 0.25 );
    sheet.setMargin ( Sheet.BottomMargin, 0.5 );

    return sheet;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:36,代碼來源:ExportEventsImpl.java

示例2: exportMotionExcel

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的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


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