Package org.apache.poi.ss.util

Examples of org.apache.poi.ss.util.CellRangeAddress


    HSSFCellStyle emptyRightCellStyle = myWorkBook.createCellStyle();
    emptyRightCellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
   
    HSSFCellStyle emptyCellStyle = myWorkBook.createCellStyle();
   
    cra = new CellRangeAddress(mySheet.getLastRowNum()+1, mySheet.getLastRowNum()+1, 0, 7);
    mySheet.addMergedRegion( cra );
     
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 240);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
View Full Code Here


    myCell.setCellValue("");
    myCell.setCellStyle(emptyRightCellStyle);
  }
 
  public void writeMonth(int k, int j){
    cra = new CellRangeAddress(mySheet.getLastRowNum()+1, mySheet.getLastRowNum()+1, 0, 7);
    mySheet.addMergedRegion( cra );
   
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 240);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
View Full Code Here

              "Soz. Vers. AN",
              "Gehalt Netto",
              "Soz. Vers. AG",
              "Gesamtkosten"};

    CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 7);
    mySheet.addMergedRegion( cra );
   
    myRow = mySheet.createRow(0);
   
    myCell = myRow.createCell(0);
    myCell.setCellValue("�bersicht aller Abrechnungen im Monat "+df.format(startDat));
   
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 350);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setFillForegroundColor(HSSFColor.GREY_80_PERCENT.index);
    myCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    myCellStyle.setFont(myFont);
    myCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
   
    myCell.setCellStyle(myCellStyle);
   
    for(int i = 1; i < 7; i++){
      myCell = myRow.createCell(i);
      myCellStyle = myWorkBook.createCellStyle();
      myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
      myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
      myCell.setCellStyle(myCellStyle);
    }
    myCell = myRow.createCell(7);
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
    myCell.setCellStyle(myCellStyle);
   
   
    myRow = mySheet.createRow(mySheet.getLastRowNum()+1);
   
    myFont = myWorkBook.createFont();
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
   
    myCellStyle = myWorkBook.createCellStyle();
    myCellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
    myCellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
    myCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    myCellStyle.setFont(myFont);
   
    for(int i = 0; i < header.length; i++){
        myCell = myRow.createCell(i);
        myCell.setCellValue(header[i]);
        myCell.setCellStyle(myCellStyle);
    }
   
    HSSFCellStyle dateCellStyle = myWorkBook.createCellStyle();
    dateCellStyle.setDataFormat(HSSFDataFormat
        .getBuiltinFormat("m/d/yy"));
    dateCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    dateCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
   
    HSSFCellStyle euroCellStyle = myWorkBook.createCellStyle();
    euroCellStyle.setDataFormat(myWorkBook.createDataFormat().getFormat("#,##0.00 �"));
    euroCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    euroCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
   
    HSSFCellStyle euroRightCellStyle = myWorkBook.createCellStyle();
    euroRightCellStyle.setDataFormat(myWorkBook.createDataFormat().getFormat("#,##0.00 �"));
    euroRightCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    euroRightCellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
   
    while(rs.next()){
      myRow = mySheet.createRow(mySheet.getLastRowNum()+1);
      if(rs.getInt("PersID") != persID){
        if(!firstEntry){
          createSumRows();
        }
        myCell = myRow.createCell(0);
        myCell.setCellValue(rs.getString("PersID")+": "+rs.getString("Nachname")+", "+rs.getString("Vorname"));
        myCellStyle = myWorkBook.createCellStyle();
        myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        myCell.setCellStyle(myCellStyle);
       
        myCell = myRow.createCell(1);
        myCell.setCellValue(rs.getDate("BuchungsDat"));
        myCell.setCellStyle(dateCellStyle);
       
        myCell = myRow.createCell(2);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
                  rs.getDouble("gehaltausgezahlt.sonstBezug")-
                  rs.getDouble("gehaltausgezahlt.sonstAbzug"));
        myCell.setCellStyle(euroCellStyle);
        gesGesamtgehalt += myCell.getNumericCellValue();
        mitarbGesamtgehalt += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(3);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.LSt")+
                  rs.getDouble("gehaltausgezahlt.KiSt")+
                  rs.getDouble("gehaltausgezahlt.Soli"));
        myCell.setCellStyle(euroCellStyle);
        gesSteuerabzug += myCell.getNumericCellValue();
        mitarbSteuerabzug += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(4);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAN")+
                  rs.getDouble("gehaltausgezahlt.KVAN")+
                  rs.getDouble("gehaltausgezahlt.ALVAN")+
                  rs.getDouble("gehaltausgezahlt.PVAN"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAN += myCell.getNumericCellValue();
        mitarbSozVersAN += myCell.getNumericCellValue();

        myCell = myRow.createCell(5);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehNetto"));
        myCell.setCellStyle(euroCellStyle);
        gesGehaltNetto += myCell.getNumericCellValue();
        mitarbGehaltNetto += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(6);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAG")+
                    rs.getDouble("gehaltausgezahlt.KVAG")+
                    rs.getDouble("gehaltausgezahlt.ALVAG")+
                    rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAG += myCell.getNumericCellValue();
        mitarbSozVersAG += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(7);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
            rs.getDouble("gehaltausgezahlt.sonstBezug")-
            rs.getDouble("gehaltausgezahlt.sonstAbzug")+
            rs.getDouble("gehaltausgezahlt.RVAG")+
            rs.getDouble("gehaltausgezahlt.KVAG")+
            rs.getDouble("gehaltausgezahlt.ALVAG")+
            rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroRightCellStyle);
        gesGesamtkosten += myCell.getNumericCellValue();
        mitarbGesamtkosten += myCell.getNumericCellValue();
       
        firstEntry = false;
        persID = rs.getInt("PersID");
      }else{
        myCell = myRow.createCell(0);
        myCellStyle = myWorkBook.createCellStyle();
        myCellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
        myCell.setCellStyle(myCellStyle);
       
        myCell = myRow.createCell(1);
        myCell.setCellValue(rs.getDate("BuchungsDat"));
        myCell.setCellStyle(dateCellStyle);

        myCell = myRow.createCell(2);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
                  rs.getDouble("gehaltausgezahlt.sonstBezug")-
                  rs.getDouble("gehaltausgezahlt.sonstAbzug"));
        myCell.setCellStyle(euroCellStyle);
        gesGesamtgehalt += myCell.getNumericCellValue();
        mitarbGesamtgehalt += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(3);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.LSt")+
                  rs.getDouble("gehaltausgezahlt.KiSt")+
                  rs.getDouble("gehaltausgezahlt.Soli"));
        myCell.setCellStyle(euroCellStyle);
        gesSteuerabzug += myCell.getNumericCellValue();
        mitarbSteuerabzug += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(4);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAN")+
                  rs.getDouble("gehaltausgezahlt.KVAN")+
                  rs.getDouble("gehaltausgezahlt.ALVAN")+
                  rs.getDouble("gehaltausgezahlt.PVAN"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAN += myCell.getNumericCellValue();
        mitarbSozVersAN += myCell.getNumericCellValue();

        myCell = myRow.createCell(5);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehNetto"));
        myCell.setCellStyle(euroCellStyle);
        gesGehaltNetto += myCell.getNumericCellValue();
        mitarbGehaltNetto += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(6);     
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.RVAG")+
                    rs.getDouble("gehaltausgezahlt.KVAG")+
                    rs.getDouble("gehaltausgezahlt.ALVAG")+
                    rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroCellStyle);
        gesSozVersAG += myCell.getNumericCellValue();
        mitarbSozVersAG += myCell.getNumericCellValue();
       
        myCell = myRow.createCell(7);
        myCell.setCellValue(rs.getDouble("gehaltausgezahlt.GehBrutto")+
            rs.getDouble("gehaltausgezahlt.sonstBezug")-
            rs.getDouble("gehaltausgezahlt.sonstAbzug")+
            rs.getDouble("gehaltausgezahlt.RVAG")+
            rs.getDouble("gehaltausgezahlt.KVAG")+
            rs.getDouble("gehaltausgezahlt.ALVAG")+
            rs.getDouble("gehaltausgezahlt.PVAG"));
        myCell.setCellStyle(euroRightCellStyle);
        gesGesamtkosten += myCell.getNumericCellValue();
        mitarbGesamtkosten += myCell.getNumericCellValue();
      }
    }
    createSumRows();
   
    cra = new CellRangeAddress(mySheet.getLastRowNum(), mySheet.getLastRowNum(), 0, 7);
    mySheet.addMergedRegion( cra );
     
    myFont = myWorkBook.createFont();
    myFont.setFontHeight((short) 240);
    myFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
View Full Code Here

                CFRuleRecord.ComparisonOperator.BETWEEN, "'first sheet'!D1", "'other sheet'!D1");

        HSSFConditionalFormattingRule [] cfRules = { rule1 };

        CellRangeAddress[] regions = {
            new CellRangeAddress(2, 4, 0, 0), // A3:A5
        };
        sheetCF.addConditionalFormatting(regions, cfRules);

        wb.setSheetOrder("other sheet", 0);
View Full Code Here

     */
    protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
        List<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
        //move merged regions completely if they fall within the new region boundaries when they are shifted
        for (int i = 0; i < getNumMergedRegions(); i++) {
             CellRangeAddress merged = getMergedRegion(i);

             boolean inStart= (merged.getFirstRow() >= startRow || merged.getLastRow() >= startRow);
             boolean inEnd  = (merged.getFirstRow() <= endRow   || merged.getLastRow() <= endRow);

             //don't check if it's not within the shifted area
             if (!inStart || !inEnd) {
                continue;
             }

             //only shift if the region outside the shifted rows is not merged too
             if (!SheetUtil.containsCell(merged, startRow-1, 0) &&
                 !SheetUtil.containsCell(merged, endRow+1, 0)){
                 merged.setFirstRow(merged.getFirstRow()+n);
                 merged.setLastRow(merged.getLastRow()+n);
                 //have to remove/add it back
                 shiftedRegions.add(merged);
                 removeMergedRegion(i);
                 i = i -1; // we have to back up now since we removed one
             }
        }

        //read so it doesn't get shifted again
        Iterator<CellRangeAddress> iterator = shiftedRegions.iterator();
        while (iterator.hasNext()) {
            CellRangeAddress region = iterator.next();

            this.addMergedRegion(region);
        }
    }
View Full Code Here

        if (!(rec instanceof FormulaRecordAggregate)) {
            String ref = new CellReference(cell).formatAsString();
            throw new IllegalArgumentException("Cell " + ref + " is not part of an array formula.");
        }
        FormulaRecordAggregate fra = (FormulaRecordAggregate) rec;
        CellRangeAddress range = fra.removeArrayFormula(cell.getRowIndex(), cell.getColumnIndex());

        CellRange<HSSFCell> result = getCellRange(range);
        // clear all cells in the range
        for (Cell c : result) {
            c.setCellType(Cell.CELL_TYPE_BLANK);
View Full Code Here

        return _fileOpts;
    }


    public HyperlinkRecord(RecordInputStream in) {
        _range = new CellRangeAddress(in);

        _guid = new GUID(in);

        /**
         * streamVersion (4 bytes): An unsigned integer that specifies the version number
View Full Code Here

            rule1, rule2
        };

        short col = 1;
        CellRangeAddress [] regions = {
            new CellRangeAddress(0, 65535, col, col)
        };

        sheetCF.addConditionalFormatting(regions, cfRules);
        sheetCF.addConditionalFormatting(regions, cfRules);

        // Verification
        assertEquals(2, sheetCF.getNumConditionalFormattings());
        sheetCF.removeConditionalFormatting(1);
        assertEquals(1, sheetCF.getNumConditionalFormattings());
        ConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
        assertNotNull(cf);

        regions = cf.getFormattingRanges();
        assertNotNull(regions);
        assertEquals(1, regions.length);
        CellRangeAddress r = regions[0];
        assertEquals(1, r.getFirstColumn());
        assertEquals(1, r.getLastColumn());
        assertEquals(0, r.getFirstRow());
        assertEquals(65535, r.getLastRow());

        assertEquals(2, cf.getNumberOfRules());

        rule1 = cf.getRule(0);
        assertEquals("7",rule1.getFormula1());
View Full Code Here

   
    /**
     * Initialize a new url link
     */
    public void newUrlLink() {
        _range = new CellRangeAddress(0, 0, 0, 0);
        _guid = STD_MONIKER;
        _linkOpts = HLINK_URL | HLINK_ABS | HLINK_LABEL;
        setLabel("");
        _moniker = URL_MONIKER;
        setAddress("");
View Full Code Here

    /**
     * Initialize a new file link
     */
    public void newFileLink() {
        _range = new CellRangeAddress(0, 0, 0, 0);
        _guid = STD_MONIKER;
        _linkOpts = HLINK_URL | HLINK_LABEL;
        _fileOpts = 0;
        setLabel("");
        _moniker = FILE_MONIKER;
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.util.CellRangeAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.