本文整理汇总了Java中org.apache.poi.ss.usermodel.PrintSetup.setPaperSize方法的典型用法代码示例。如果您正苦于以下问题:Java PrintSetup.setPaperSize方法的具体用法?Java PrintSetup.setPaperSize怎么用?Java PrintSetup.setPaperSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.PrintSetup
的用法示例。
在下文中一共展示了PrintSetup.setPaperSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyPrintSetup
import org.apache.poi.ss.usermodel.PrintSetup; //导入方法依赖的package包/类
/**
* fromIdxのシートからtoIdxシートへの印刷設定のコピーを行う
* @param workbook fromIdx、toIdxのシートを含むworkbook
* @param fromIdx コピー元シートのインデックス
* @param sheet コピー先シート
*/
public static void copyPrintSetup( Workbook workbook, int fromIdx, Sheet toSheet) {
Sheet fromSheet = workbook.getSheetAt( fromIdx);
// 印刷設定
PrintSetup fromPrintSetup = fromSheet.getPrintSetup();
PrintSetup printSetup = toSheet.getPrintSetup();
printSetup.setCopies( fromPrintSetup.getCopies());
printSetup.setDraft( fromPrintSetup.getDraft());
printSetup.setFitHeight( fromPrintSetup.getFitHeight());
printSetup.setFitWidth( fromPrintSetup.getFitWidth());
printSetup.setFooterMargin( fromPrintSetup.getFooterMargin());
printSetup.setHeaderMargin( fromPrintSetup.getHeaderMargin());
printSetup.setHResolution( fromPrintSetup.getHResolution());
printSetup.setLandscape( fromPrintSetup.getLandscape());
printSetup.setLeftToRight( fromPrintSetup.getLeftToRight());
printSetup.setNoColor( fromPrintSetup.getNoColor());
printSetup.setNoOrientation( fromPrintSetup.getNoOrientation());
printSetup.setPageStart( fromPrintSetup.getPageStart());
printSetup.setPaperSize( fromPrintSetup.getPaperSize());
printSetup.setScale( fromPrintSetup.getScale());
printSetup.setUsePage( fromPrintSetup.getUsePage());
printSetup.setValidSettings( fromPrintSetup.getValidSettings());
printSetup.setVResolution( fromPrintSetup.getVResolution());
// 印刷範囲
String printArea = workbook.getPrintArea( fromIdx);
if ( printArea != null) {
if ( printArea.contains( "!")) {
printArea = printArea.substring( printArea.indexOf( "!") + 1);
}
int toIdx = workbook.getSheetIndex( toSheet);
workbook.setPrintArea( toIdx, printArea);
}
// タイトル行、タイトル列
toSheet.setRepeatingColumns( fromSheet.getRepeatingColumns());
toSheet.setRepeatingRows( fromSheet.getRepeatingRows());
}
示例2: setupPageSize
import org.apache.poi.ss.usermodel.PrintSetup; //导入方法依赖的package包/类
private void setupPageSize(HandlerState state, IPageContent page) {
PrintSetup printSetup = state.currentSheet.getPrintSetup();
printSetup.setPaperSize(state.getSmu().getPaperSizeFromString(page.getPageType()));
if( page.getOrientation() != null ) {
if( "landscape".equals(page.getOrientation())) {
printSetup.setLandscape(true);
}
}
}
示例3: copyPrintSetup
import org.apache.poi.ss.usermodel.PrintSetup; //导入方法依赖的package包/类
/**
* 复制模板工作表的打印区域到数据工作表中
*
* @author ZhengWei(HY)
* @createDate 2017-03-17
* @version v1.0
*
* @param i_FromSheet 源工作表
* @param i_ToSheet 目标工作表
*/
public final static void copyPrintSetup(Sheet i_FromSheet ,Sheet i_ToSheet)
{
PrintSetup v_FromPrintSetup = i_FromSheet.getPrintSetup();
PrintSetup v_ToPrintSetup = i_ToSheet .getPrintSetup();
v_ToPrintSetup.setCopies( v_FromPrintSetup.getCopies());
v_ToPrintSetup.setDraft( v_FromPrintSetup.getDraft()); // 值为true时,表示用草稿品质打印
v_ToPrintSetup.setFitHeight( v_FromPrintSetup.getFitHeight()); // 设置页高
v_ToPrintSetup.setFitWidth( v_FromPrintSetup.getFitWidth()); // 设置页宽
v_ToPrintSetup.setFooterMargin( v_FromPrintSetup.getFooterMargin());
v_ToPrintSetup.setHeaderMargin( v_FromPrintSetup.getHeaderMargin());
v_ToPrintSetup.setHResolution( v_FromPrintSetup.getHResolution());
v_ToPrintSetup.setLandscape( v_FromPrintSetup.getLandscape()); // true,则表示页面方向为横向;否则为纵向
v_ToPrintSetup.setLeftToRight( v_FromPrintSetup.getLeftToRight()); // true表示“先行后列”;false表示“先列后行”
v_ToPrintSetup.setNoColor( v_FromPrintSetup.getNoColor()); // 值为true时,表示单色打印
v_ToPrintSetup.setNoOrientation(v_FromPrintSetup.getNoOrientation());
v_ToPrintSetup.setNotes( v_FromPrintSetup.getNotes()); // 设置打印批注
v_ToPrintSetup.setPageStart( v_FromPrintSetup.getPageStart()); // 设置打印起始页码
v_ToPrintSetup.setPaperSize( v_FromPrintSetup.getPaperSize()); // 纸张类型 A4纸 HSSFPrintSetup.A4_PAPERSIZE
v_ToPrintSetup.setScale( v_FromPrintSetup.getScale()); // 缩放比例80%(设置为0-100之间的值)
v_ToPrintSetup.setUsePage( v_FromPrintSetup.getUsePage()); // 设置打印起始页码是否使用"自动"
v_ToPrintSetup.setValidSettings(v_FromPrintSetup.getValidSettings());
v_ToPrintSetup.setVResolution( v_FromPrintSetup.getVResolution());
// 设置打印参数
if ( i_ToSheet instanceof HSSFSheet )
{
((HSSFPrintSetup)v_ToPrintSetup).setOptions(((HSSFPrintSetup)v_FromPrintSetup).getOptions());
i_ToSheet.setMargin(HSSFSheet.TopMargin ,i_FromSheet.getMargin(HSSFSheet.TopMargin)); // 页边距(上)
i_ToSheet.setMargin(HSSFSheet.BottomMargin ,i_FromSheet.getMargin(HSSFSheet.BottomMargin)); // 页边距(下)
i_ToSheet.setMargin(HSSFSheet.LeftMargin ,i_FromSheet.getMargin(HSSFSheet.LeftMargin)); // 页边距(左)
i_ToSheet.setMargin(HSSFSheet.RightMargin ,i_FromSheet.getMargin(HSSFSheet.RightMargin)); // 页边距(右)
i_ToSheet.setMargin(HSSFSheet.HeaderMargin ,i_FromSheet.getMargin(HSSFSheet.HeaderMargin)); // 页眉
i_ToSheet.setMargin(HSSFSheet.FooterMargin ,i_FromSheet.getMargin(HSSFSheet.FooterMargin)); // 页脚
}
else if ( i_ToSheet instanceof SXSSFSheet )
{
((XSSFPrintSetup)v_ToPrintSetup).setOrientation(((XSSFPrintSetup)v_FromPrintSetup).getOrientation()); // 设置方向
i_ToSheet.setMargin(SXSSFSheet.TopMargin ,i_FromSheet.getMargin(SXSSFSheet.TopMargin)); // 页边距(上)
i_ToSheet.setMargin(SXSSFSheet.BottomMargin ,i_FromSheet.getMargin(SXSSFSheet.BottomMargin)); // 页边距(下)
i_ToSheet.setMargin(SXSSFSheet.LeftMargin ,i_FromSheet.getMargin(SXSSFSheet.LeftMargin)); // 页边距(左)
i_ToSheet.setMargin(SXSSFSheet.RightMargin ,i_FromSheet.getMargin(SXSSFSheet.RightMargin)); // 页边距(右)
i_ToSheet.setMargin(SXSSFSheet.HeaderMargin ,i_FromSheet.getMargin(SXSSFSheet.HeaderMargin)); // 页眉
i_ToSheet.setMargin(SXSSFSheet.FooterMargin ,i_FromSheet.getMargin(SXSSFSheet.FooterMargin)); // 页脚
}
else if ( i_ToSheet instanceof XSSFSheet )
{
((XSSFPrintSetup)v_ToPrintSetup).setOrientation(((XSSFPrintSetup)v_FromPrintSetup).getOrientation()); // 设置方向
i_ToSheet.setMargin(XSSFSheet.TopMargin ,i_FromSheet.getMargin(XSSFSheet.TopMargin)); // 页边距(上)
i_ToSheet.setMargin(XSSFSheet.BottomMargin ,i_FromSheet.getMargin(XSSFSheet.BottomMargin)); // 页边距(下)
i_ToSheet.setMargin(XSSFSheet.LeftMargin ,i_FromSheet.getMargin(XSSFSheet.LeftMargin)); // 页边距(左)
i_ToSheet.setMargin(XSSFSheet.RightMargin ,i_FromSheet.getMargin(XSSFSheet.RightMargin)); // 页边距(右)
i_ToSheet.setMargin(XSSFSheet.HeaderMargin ,i_FromSheet.getMargin(XSSFSheet.HeaderMargin)); // 页眉
i_ToSheet.setMargin(XSSFSheet.FooterMargin ,i_FromSheet.getMargin(XSSFSheet.FooterMargin)); // 页脚
}
copyHeaderFooter(i_FromSheet.getHeader() ,i_ToSheet.getHeader());
copyHeaderFooter(i_FromSheet.getFooter() ,i_ToSheet.getFooter());
}