<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 5,  comments - 7,  trackbacks - 0
     

    JXL的打印設(shè)置在jxl.SheetSettings這個(gè)類中,我們可以通過(guò)方法Sheet(或者WritableSheet#getSettings()獲取。

    1.頁(yè)面

    1.1方向

    SheetSetting#setOrientation(PageOrientation po)

    參數(shù):  PageOrientation#LANDSCAPE       橫向打印

    PageOrientation# PORTRAIT       縱向打印

    1.2縮放

    1.2.1縮放比例(A) SheetSetting #setScaleFactor (int);百分比形式

    1.2.2調(diào)整(F)

    頁(yè)寬 SheetSetting #setFitWidth(int);

    頁(yè)高 SheetSetting #setFitHeight(int);

    1.3紙張大小(Z) SheetSetting #setPaperSize (PaperSize);

    紙張大小的定義說(shuō)明參見(jiàn)PaperSize類中的常量。

    1.4起始頁(yè)碼(R) SheetSetting #setPageStrart(int);[默認(rèn)狀態(tài)]

    2頁(yè)面距

    2.1(T) SheetSetting # setTopMargin (double);

    2.2(B) SheetSetting # setBottomMargin (double);

    2.3(L) SheetSetting # setLeftMargin (double);

    2.4(R) SheetSetting # setRightMargin (double);

    2.5頁(yè)眉(A) SheetSetting #setHeaderMargin(double);

    2.6頁(yè)腳(F) SheetSetting #setFooterMargin(double);

    2.7居中方式

    2.7.1水平(Z) SheetSetting # setHorizontalCentre (boolean);

    2.7.2垂直(V) SheetSetting #setVerticallyCenter(boolean);

    3頁(yè)眉/頁(yè)腳

    3.1頁(yè)眉SheetSetting # setHeaderHeaderFooter;

    說(shuō)明:

    對(duì)于HeaderFooter的設(shè)置,首先確定頁(yè)眉的位置(左、中、右),通過(guò)HeaderFooter#getCentre()(或者getLeft()getRight())方法獲取HeaderFooter.Contents類,之后對(duì)這個(gè)類的屬性進(jìn)行操作。

    下面簡(jiǎn)單介紹幾個(gè)常用方法:

    設(shè)置字號(hào):Contents#setFontSize(int)

    設(shè)置字體:Contents#setFontName(String)

    設(shè)置內(nèi)容:Contents# appendString),還有appendDate()當(dāng)前日期等等,具體參考Contents類說(shuō)明

    3.2頁(yè)腳SheetSetting # setFooterHeaderFooter);

    說(shuō)明同上

    4工作表

    4.1打印區(qū)域

    SheetSettings #setPrintArea(firstCol, firstRow, lastCol, lastRow)

    4.2打印標(biāo)題

    SheetSettings#setPrintTitles (firstRow,lastRow,firstCol,lastCol);

    SheetSettings#setPrintTitlesCol(firstCol,lastCol)

    SheetSettings#setPrintTitlesRow(firstRow,lastRow)

    另有一些其他的設(shè)置可在JXL API中找到,不多說(shuō)了。

    附件:通常在Excel中設(shè)置好打印,再將其讀出來(lái)設(shè)置到當(dāng)前頁(yè)中來(lái),附上代碼:

    在向Sheet頁(yè)寫(xiě)數(shù)據(jù)之前:

    1//獲取原Sheet頁(yè)的設(shè)置 
    2
    3SheetSettings sheetSetting=sheet.getSettings(); 
    4

    5//將原sheet頁(yè)的打印設(shè)置設(shè)置到當(dāng)前Sheet頁(yè)中 

    6
    7sheet=new MjJxlExcelCopyPrintSetting().copySheetSettingToSheet(sheet, sheetSetting);
    8

      1下面是MjJxlExcelCopyPrintSetting的代碼:
      2

      3import
     jxl.HeaderFooter; 
      4import
     jxl.Range; 
      5import
     jxl.SheetSettings; 
      6import
     jxl.format.PageOrientation; 
      7import
     jxl.format.PaperSize; 
      8import
     jxl.write.WritableSheet; 
      9

     10
    /** 
     11
     * 讀取Jxl方法并設(shè)置 
     12

     13 * @author
     邱大為 
     14 * @version
     1.0 
     15 */
     
     16public class MjJxlExcelCopyPrintSetting 

     17    
    /** 
     18
         * 該方法將setting設(shè)置到sheet中 
     19     * @param
     sheet 需要設(shè)置的sheet 
     20     * @param
     setting 被設(shè)置的屬性 
     21     * @return
     
     22     */
     
     23    public WritableSheet copySheetSettingToSheet(WritableSheet sheet,SheetSettings setting)

     24//      設(shè)置原Sheet打印屬性到新Sheet頁(yè) 

     25        SheetSettings sheetSettings= sheet.getSettings(); 
     26
             
     27
            sheetSettings.setAutomaticFormulaCalculation(setting.getAutomaticFormulaCalculation()); 
     28
            sheetSettings.setBottomMargin(setting.getBottomMargin()); 
     29
            sheetSettings.setCopies(setting.getCopies()); 
     30
            sheetSettings.setDefaultColumnWidth(setting.getDefaultColumnWidth()); 
     31
            sheetSettings.setDefaultRowHeight(setting.getDefaultRowHeight()); 
     32
            sheetSettings.setDisplayZeroValues(setting.getDisplayZeroValues()); 
     33
            sheetSettings.setFitHeight(setting.getFitHeight()); 
     34
            sheetSettings.setFitToPages(setting.getFitToPages()); 
     35
            sheetSettings.setFitWidth(setting.getFitWidth()); 
     36
             
     37        HeaderFooter footer=
    setting.getFooter(); 
     38        if(footer!=null)

     39
                sheetSettings.setFooter(footer); 
     40        }
     
     41
            sheetSettings.setFooterMargin(setting.getFooterMargin()); 
     42        HeaderFooter header=
    setting.getHeader(); 
     43        if(header!=null)

     44
                sheetSettings.setHeader(header); 
     45        }
     
     46
            sheetSettings.setHeaderMargin(setting.getHeaderMargin()); 
     47
            sheetSettings.setHidden(setting.isHidden()); 
     48
            sheetSettings.setHorizontalCentre(setting.isHorizontalCentre()); 
     49
            sheetSettings.setHorizontalFreeze(setting.getHorizontalFreeze()); 
     50
            sheetSettings.setHorizontalPrintResolution(setting.getHorizontalPrintResolution()); 
     51
            sheetSettings.setLeftMargin(setting.getLeftMargin()); 
     52
            sheetSettings.setNormalMagnification(setting.getNormalMagnification()); 
     53        PageOrientation pageOrientation=
    setting.getOrientation(); 
     54        if(pageOrientation!=null)

     55
                sheetSettings.setOrientation(pageOrientation); 
     56        }
     
     57
            sheetSettings.setPageBreakPreviewMagnification(setting.getPageBreakPreviewMagnification()); 
     58
            sheetSettings.setPageBreakPreviewMode(setting.getPageBreakPreviewMode()); 
     59
            sheetSettings.setPageStart(setting.getPageStart()); 
     60        PaperSize paperSize=
    setting.getPaperSize(); 
     61        if(paperSize!=null)

     62
                sheetSettings.setPaperSize(setting.getPaperSize()); 
     63        }
     
     64
             
     65
            sheetSettings.setPassword(setting.getPassword()); 
     66
            sheetSettings.setPasswordHash(setting.getPasswordHash()); 
     67        Range printArea=
    setting.getPrintArea(); 
     68        if(printArea!=null)

     69            sheetSettings.setPrintArea(printArea.getTopLeft()==null?0
    :printArea.getTopLeft().getColumn(),  
     70                    printArea.getTopLeft()==null?0
    :printArea.getTopLeft().getRow(),  
     71                            printArea.getBottomRight()==null?0
    :printArea.getBottomRight().getColumn(),  
     72                                    printArea.getBottomRight()==null?0
    :printArea.getBottomRight().getRow()); 
     73        }
     
     74
             
     75
            sheetSettings.setPrintGridLines(setting.getPrintGridLines()); 
     76
            sheetSettings.setPrintHeaders(setting.getPrintHeaders()); 
     77
             
     78        Range printTitlesCol=
    setting.getPrintTitlesCol(); 
     79        if(printTitlesCol!=null)

     80        sheetSettings.setPrintTitlesCol(printTitlesCol.getTopLeft()==null?0
    :printTitlesCol.getTopLeft().getColumn(),  
     81                printTitlesCol.getBottomRight()==null?0
    :printTitlesCol.getBottomRight().getColumn()); 
     82        }
     
     83        Range printTitlesRow=
    setting.getPrintTitlesRow(); 
     84        if(printTitlesRow!=null)

     85            sheetSettings.setPrintTitlesRow(printTitlesRow.getTopLeft()==null?0
    :printTitlesRow.getTopLeft().getRow(),  
     86                    printTitlesRow.getBottomRight()==null?0
    :printTitlesRow.getBottomRight().getRow()); 
     87        }
     
     88
             
     89
            sheetSettings.setProtected(setting.isProtected()); 
     90
            sheetSettings.setRecalculateFormulasBeforeSave(setting.getRecalculateFormulasBeforeSave()); 
     91
            sheetSettings.setRightMargin(setting.getRightMargin()); 
     92
            sheetSettings.setScaleFactor(setting.getScaleFactor()); 
     93
            sheetSettings.setSelected(setting.isSelected()); 
     94
            sheetSettings.setShowGridLines(setting.getShowGridLines()); 
     95
            sheetSettings.setTopMargin(setting.getTopMargin()); 
     96
            sheetSettings.setVerticalCentre(setting.isVerticalCentre()); 
     97
            sheetSettings.setVerticalFreeze(setting.getVerticalFreeze()); 
     98
            sheetSettings.setVerticalPrintResolution(setting.getVerticalPrintResolution()); 
     99
            sheetSettings.setZoomFactor(setting.getZoomFactor()); 
    100        return
     sheet; 
    101    }
     
    102}
     
    103

    104

    105


    1.頁(yè)面
    1.1
    方向
    1.1.1
    縱向(T)HSSFPrintSetup#setLandscape(false); [默認(rèn)狀態(tài)]
    1.1.2
    橫向
    (L)HSSFPrintSetup#setLandscape(true);

    1.2
    縮放

    1.2.1
    縮放比例(A)HSSFPrintSetup#setScale((short) 100);[默認(rèn)狀態(tài)]
    1.2.2
    調(diào)整
    (F)
    頁(yè)寬
     HSSFPrintSetup#setFitWidth((short) 1);
    頁(yè)高
     HSSFPrintSetup#setFitHeight((short) 0);

    1.3
    紙張大小
    (Z)HSSFPrintSetup#setPageSize(HSSFPrintSetup.LETTER_PAPERSIZE);
    紙張大小的定義說(shuō)明:

    public static final short LETTER_PAPERSIZE = 1;
    public static final short LEGAL_PAPERSIZE = 5;
    public static final short EXECUTIVE_PAPERSIZE = 7;
    public static final short A4_PAPERSIZE = 9;
    public static final short A5_PAPERSIZE = 11;
    public static final short ENVELOPE_10_PAPERSIZE = 20;
    public static final short ENVELOPE_DL_PAPERSIZE = 27;
    public static final short ENVELOPE_CS_PAPERSIZE = 28;
    public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;

    1.4
    打印質(zhì)量(Q)HSSFPrintSetup#setVResolution((short) 300)
    1.5
    起始頁(yè)碼(R)HSSFPrintSetup#setPageStrart((short) 0);[默認(rèn)狀態(tài)
    ]

    2
    頁(yè)面距

    2.1
    (T)HSSFSheet#setMargin(HSSFSheet.TopMargin,(short)0.6);
    2.2
    (B)HSSFSheet#setMargin(HSSFSheet.BottomMargin,(short)0.6);
    2.3
    (L)HSSFSheet#setMargin(HSSFSheet.LeftMargin,(short)0.6);
    2.4
    (R)HSSFSheet#setMargin(HSSFSheet.RightMargin,(short)0.2);
    2.5
    頁(yè)眉
    (A)HSSFPrintSetup#setHeaderMargin((double)0.2);
    2.6
    頁(yè)腳
    (F)HSSFPrintSetup#setFooterMargin((double)0.6);
    2.7
    居中方式

    2.7.1
    水平(Z)HSSFSheet#setHorizontallyCenter(false);
    2.7.2
    垂直
    (V)HSSFSheet#setVerticallyCenter(false);

    3
    頁(yè)眉/頁(yè)腳

    3.1
    頁(yè)眉HSSFHeader#setLeftHSSFHeader.date();
    說(shuō)明
    :
    首先獲得HSSFHeader對(duì)象

    確定頁(yè)眉的顯示位置(,左邊顯示頁(yè)眉HSSFHeader#setLeft(顯示內(nèi)容))
    可使用
    HSSFHeader#setLeft,setCenter,setRight

    3.2
    頁(yè)腳HSSFFotter#setLeftHSSFFotter.page()+”/”+HSSFFotter.numPages());

    說(shuō)明同3.1
    首先獲得HSSFFotter對(duì)象

    確定頁(yè)眉的顯示位置(,左邊顯示頁(yè)眉HSSFFotter#setLeft(顯示內(nèi)容))
    可使用
    HSSFFotter#setLeft,setCenter,setRight

    4
    工作表

    4.1
    打印區(qū)域
    HSSFWorkbook#setPrintArea(intsheetIndex,
    intstartColumn,
    intendColumn,
    intstartRow,
    intendRow);
    參數(shù)的說(shuō)明
    sheetIndex–
    0開(kāi)始的sheet的索引編號(hào)
    startColumn-
    打印區(qū)域的開(kāi)始列號(hào)
    endColumn-
    打印區(qū)域的結(jié)束列號(hào)
    startRow-
    打印區(qū)域的開(kāi)始行號(hào)
    endRow-
    打印區(qū)域的結(jié)束行號(hào)

    4.2
    打印標(biāo)題
    HSSFWorkbook#setRepeatingRowsAndColumns(intsheetIndex,
    intstartColumn,
    intendColumn,
    intstartRow,
    intendRow);
    參數(shù)說(shuō)明同4.1
    使用說(shuō)明:

    僅僅設(shè)置左端標(biāo)題列:
    workbook.setRepeatingRowsAndColumns(0,0,1,-1-1);

    僅僅設(shè)置頂端標(biāo)題行:
    workbook.setRepeatingRowsAndColumns(0,-1,-1,0,4);

    同時(shí)設(shè)置左端和頂端標(biāo)題:
    workbook.setRepeatingRowsAndColumns(0,-1,-1,-1,-1);

    4.3
    打印
    網(wǎng)格線(G)HSSFSheet#setPrintGridlines(false);
    單色打印
    (B)HSSFPrintSetup#setNoColor(false);
    按草稿方式(Q):HSSFPrintSetup#setDraft(false)

    行號(hào)列標(biāo)(L):(很抱歉,還沒(méi)有找到)
    批注(M):(很抱歉,還沒(méi)有找到)
    錯(cuò)誤單元格打印為(E):(很抱歉,還沒(méi)有找到)

    4.4
    打印順序

    HSSFPrintSetup#setLeftToRight(false) 


    posted on 2008-11-25 12:59 Vincent-chen 閱讀(8356) 評(píng)論(1)  編輯  收藏 所屬分類: PrintJXL
    主站蜘蛛池模板: 久久丫精品国产亚洲av不卡| 亚洲w码欧洲s码免费| 亚洲午夜久久久久妓女影院| 无码免费又爽又高潮喷水的视频 | 一区二区免费在线观看| 亚洲国产成人影院播放| 无码免费又爽又高潮喷水的视频 | 亚洲AV无码一区二区二三区软件| 两性色午夜视频免费播放| 亚洲乳大丰满中文字幕| 十八禁视频在线观看免费无码无遮挡骂过| 国精无码欧精品亚洲一区| 美女视频黄a视频全免费网站色窝| 亚洲s色大片在线观看| 99re在线这里只有精品免费| 亚洲码在线中文在线观看| 久草免费在线观看视频| 亚洲AV成人影视在线观看 | 一区二区三区四区免费视频 | 成人免费黄色网址| 狠狠色香婷婷久久亚洲精品| 搡女人免费视频大全| 亚洲AV成人一区二区三区观看| 国产一级特黄高清免费大片| 特级毛片A级毛片免费播放| 久久亚洲国产成人影院网站| 在线毛片片免费观看| 亚洲精品在线播放| 成全视频在线观看免费高清动漫视频下载| 亚洲精品无码中文久久字幕| 免费在线观看你懂的| 国产vA免费精品高清在线观看| 亚洲国产精品无码久久久蜜芽| 24小时日本电影免费看| 最新国产精品亚洲| 免费一级毛片女人图片| 两个人看www免费视频| 91久久亚洲国产成人精品性色| 国产三级在线观看免费| 激情吃奶吻胸免费视频xxxx| 亚洲色欲久久久综合网|