반응형
POI 엑셀 API에서 프린트에 관련된 옵션을 지정하기 위해서 "HSSFPrintSetup" 클래스를 사용해야 한다.
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFPrintSetup.html
위 URL에 HSSFPrintSetup 클래스의 도큐먼테이션이 되어 있다.
1 2 3 4 5 6 7 8 9 10 11 12 | HSSFSheet sheet = workbook.createSheet( "Sheet1" ); //인쇄 옵션 클래스 선언 HSSFPrintSetup print = sheet.getPrintSetup(); //인쇄 용지를 A4로 설정 print.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE); //인쇄 방향을 가로로 설정 true면 가로 false면 세로(default) print.setLandscape( true ); //인쇄시 확대/축소 배율 print.setScale( ( short ) 80 ); |
위와 같이 사용하면 된다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | //A3 - 297x420 mm public static final short A3_PAPERSIZE = 8 ; //A4 Extra - 9.27 x 12.69 in public static final short A4_EXTRA_PAPERSIZE = 53 ; //A4 - 210x297 mm public static final short A4_PAPERSIZE = 9 ; //A4 Plus - 210x330 mm public static final short A4_PLUS_PAPERSIZE = 60 ; //A4 Rotated - 297x210 mm public static final short A4_ROTATED_PAPERSIZE 77 ; //A4 Small - 210x297 mm public static final short A4_SMALL_PAPERSIZE = 10 ; //A4 Transverse - 210x297 mm public static final short A4_TRANSVERSE_PAPERSIZE = 55 ; //A5 - 148x210 mm public static final short A5_PAPERSIZE = 11 ; //B4 (JIS) 250x354 mm public static final short B4_PAPERSIZE = 12 ; //B5 (JIS) 182x257 mm public static final short B5_PAPERSIZE = 13 ; //11 x 17 in public static final short ELEVEN_BY_SEVENTEEN_PAPERSIZE = 17 ; //US Envelope #10 4 1/8 x 9 1/2 public static final short ENVELOPE_10_PAPERSIZE = 20 ; //US Envelope #9 3 7/8 x 8 7/8 public static final short ENVELOPE_9_PAPERSIZE = 19 ; //Envelope C3 324x458 mm public static final short ENVELOPE_C3_PAPERSIZE = 29 ; //Envelope C4 229x324 mm public static final short ENVELOPE_C4_PAPERSIZE = 30 ; public static final short ENVELOPE_C5_PAPERSIZE = 28 ; //Envelope C6 114x162 mm public static final short ENVELOPE_C6_PAPERSIZE = 31 ; //Envelope C5 162x229 mm public static final short ENVELOPE_CS_PAPERSIZE = 28 ; //Envelope DL 110x220 mm public static final short ENVELOPE_DL_PAPERSIZE = 27 ; public static final short ENVELOPE_MONARCH_PAPERSIZE = 37 ; //US Executive 7 1/4 x 10 1/2 in public static final short EXECUTIVE_PAPERSIZE = 7 ; //Folio 8 1/2 x 13 in public static final short FOLIO8_PAPERSIZE = 14 ; //US Ledger 17 x 11 in public static final short LEDGER_PAPERSIZE = 4 ; //US Legal 8 1/2 x 14 in public static final short LEGAL_PAPERSIZE = 5 ; //US Letter 8 1/2 x 11 in public static final short LETTER_PAPERSIZE = 1 ; //US Letter Rotated 11 x 8 1/2 in public static final short LETTER_ROTATED_PAPERSIZE = 75 ; //US Letter Small 8 1/2 x 11 in public static final short LETTER_SMALL_PAGESIZE = 2 ; //US Note 8 1/2 x 11 in public static final short NOTE8_PAPERSIZE = 18 ; //Quarto 215x275 mm public static final short QUARTO_PAPERSIZE = 15 ; //US Statement 5 1/2 x 8 1/2 in public static final short STATEMENT_PAPERSIZE = 6 ; //US Tabloid 11 x 17 in public static final short TABLOID_PAPERSIZE = 3 ; //10 x 14 in public static final short TEN_BY_FOURTEEN_PAPERSIZE = 16 ; |
HSSFPrintSetup 클래스에 상수는 위와 같이 인쇄 종이 유형이 상수로 잡혀있따
A4(9), A5(11) 을 아무래도 많이 쓸듯 싶다.
반응형