本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFPrintSetup.setPaperSize方法的典型用法代码示例。如果您正苦于以下问题:Java HSSFPrintSetup.setPaperSize方法的具体用法?Java HSSFPrintSetup.setPaperSize怎么用?Java HSSFPrintSetup.setPaperSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.hssf.usermodel.HSSFPrintSetup
的用法示例。
在下文中一共展示了HSSFPrintSetup.setPaperSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSheet
import org.apache.poi.hssf.usermodel.HSSFPrintSetup; //导入方法依赖的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;
}
示例2: formatPage
import org.apache.poi.hssf.usermodel.HSSFPrintSetup; //导入方法依赖的package包/类
protected void formatPage(final HSSFSheet sheet)
{
sheet.setFitToPage(true);
// Print Setup
HSSFPrintSetup ps = sheet.getPrintSetup();
ps.setFitWidth((short)1);
ps.setNoColor(true);
ps.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);
ps.setLandscape(false);
}
示例3: setupPaper
import org.apache.poi.hssf.usermodel.HSSFPrintSetup; //导入方法依赖的package包/类
private boolean setupPaper(PaperType paperType, HSSFPrintSetup printSetup) {
boolean setup=false;
switch(paperType){
case A0:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A1:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A2:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A3:
printSetup.setPaperSize(HSSFPrintSetup.A3_PAPERSIZE);
setup=true;
break;
case A4:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
setup=true;
break;
case A5:
printSetup.setPaperSize(HSSFPrintSetup.A5_PAPERSIZE);
setup=true;
break;
case A6:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A7:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A8:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A9:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case A10:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B0:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B1:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B2:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B3:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B4:
printSetup.setPaperSize(HSSFPrintSetup.B4_PAPERSIZE);
setup=true;
break;
case B5:
printSetup.setPaperSize(HSSFPrintSetup.B5_PAPERSIZE);
setup=true;
break;
case B6:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B7:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B8:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B9:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case B10:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
case CUSTOM:
printSetup.setPaperSize(HSSFPrintSetup.A4_EXTRA_PAPERSIZE);
break;
}
return setup;
}
示例4: exportMotionExcel
import org.apache.poi.hssf.usermodel.HSSFPrintSetup; //导入方法依赖的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());
}