本文整理匯總了Java中org.apache.poi.ss.usermodel.Sheet.getPrintSetup方法的典型用法代碼示例。如果您正苦於以下問題:Java Sheet.getPrintSetup方法的具體用法?Java Sheet.getPrintSetup怎麽用?Java Sheet.getPrintSetup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.usermodel.Sheet
的用法示例。
在下文中一共展示了Sheet.getPrintSetup方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private Sheet createSheet(HSSFWorkbook wb,Paper paper,String name){
Sheet sheet = null;
if(name==null){
sheet=wb.createSheet();
}else{
sheet=wb.createSheet(name);
}
PaperType paperType=paper.getPaperType();
HSSFPrintSetup printSetup=(HSSFPrintSetup)sheet.getPrintSetup();
Orientation orientation=paper.getOrientation();
if(orientation.equals(Orientation.landscape)){
printSetup.setLandscape(true);
}
setupPaper(paperType, printSetup);
int leftMargin=paper.getLeftMargin();
int rightMargin=paper.getRightMargin();
int topMargin=paper.getTopMargin();
int bottomMargin=paper.getBottomMargin();
sheet.setMargin(Sheet.LeftMargin, UnitUtils.pointToInche(leftMargin));
sheet.setMargin(Sheet.RightMargin, UnitUtils.pointToInche(rightMargin));
sheet.setMargin(Sheet.TopMargin, UnitUtils.pointToInche(topMargin));
sheet.setMargin(Sheet.BottomMargin, UnitUtils.pointToInche(bottomMargin));
return sheet;
}
示例2: createSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
protected Sheet createSheet(SXSSFWorkbook wb,Paper paper,String name){
Sheet sheet = null;
if(name==null){
sheet=wb.createSheet();
}else{
sheet=wb.createSheet(name);
}
PaperType paperType=paper.getPaperType();
XSSFPrintSetup printSetup=(XSSFPrintSetup)sheet.getPrintSetup();
Orientation orientation=paper.getOrientation();
if(orientation.equals(Orientation.landscape)){
printSetup.setOrientation(PrintOrientation.LANDSCAPE);
}
setupPaper(paperType, printSetup);
int leftMargin=paper.getLeftMargin();
int rightMargin=paper.getRightMargin();
int topMargin=paper.getTopMargin();
int bottomMargin=paper.getBottomMargin();
sheet.setMargin(Sheet.LeftMargin, UnitUtils.pointToInche(leftMargin));
sheet.setMargin(Sheet.RightMargin, UnitUtils.pointToInche(rightMargin));
sheet.setMargin(Sheet.TopMargin, UnitUtils.pointToInche(topMargin));
sheet.setMargin(Sheet.BottomMargin, UnitUtils.pointToInche(bottomMargin));
return sheet;
}
示例3: initializeSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private static CellStyle initializeSheet(Workbook wb, Sheet sheet) {
PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true);
sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
CellStyle styleTitle;
Font titleFont = wb.createFont();
titleFont.setFontHeightInPoints((short) 12);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
titleFont.setFontName("Arial");
styleTitle = wb.createCellStyle();
styleTitle.setFont(titleFont);
return styleTitle;
}
示例4: configurePrintSetup
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
protected void configurePrintSetup(Sheet sheet) {
PrintSetup printSetup = sheet.getPrintSetup();
printSetup.setLandscape(true);
sheet.setFitToPage(true);
sheet.setHorizontallyCenter(true);
}
示例5: copyPrintSetup
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的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());
}