Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Row


        Sheet sheet = wb.getSheetAt(0);


        // go through all formula cells
        for (int rInd = 2; rInd <= rowMax; rInd++) {
            Row row = sheet.getRow(rInd);

            for (int cInd = 1; cInd <= 12; cInd++) {
                Cell cell = row.getCell(cInd);
                String formula = cell.getCellFormula();
                CellReference ref = new CellReference(cell);

                //simulate correct answer
                String correct = "$A" + (rInd + 1) + "*" + columns[cInd] + "$2";
View Full Code Here


     */
    @Test
    public void bug47490() throws Exception {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
       Sheet s = wb.getSheetAt(1);
       Row r;
       DataFormatter df = new DataFormatter();
      
       r = s.getRow(1);
       assertEquals(1.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("1", df.formatCellValue(r.getCell(2)));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "@"));
       assertEquals("1", df.formatRawCellContents(1.0, -1, "General"));
             
       r = s.getRow(2);
       assertEquals(12.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("12", df.formatCellValue(r.getCell(2)));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "@"));
       assertEquals("12", df.formatRawCellContents(12.0, -1, "General"));
      
       r = s.getRow(3);
       assertEquals(123.0, r.getCell(2).getNumericCellValue(), 0);
       assertEquals("General", r.getCell(2).getCellStyle().getDataFormatString());
       assertEquals("123", df.formatCellValue(r.getCell(2)));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "@"));
       assertEquals("123", df.formatRawCellContents(123.0, -1, "General"));
    }
View Full Code Here

             new HSSFWorkbook(),
             new XSSFWorkbook()
       };
       for(Workbook wb : wbs) {
          Sheet s = wb.createSheet();
          Row r = s.createRow(0);
         
          // Setup
          Cell cn = r.createCell(0, Cell.CELL_TYPE_NUMERIC);
          cn.setCellValue(1.2);
          Cell cs = r.createCell(1, Cell.CELL_TYPE_STRING);
          cs.setCellValue("Testing");
         
          Cell cfn = r.createCell(2, Cell.CELL_TYPE_FORMULA);
          cfn.setCellFormula("A1")
          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
View Full Code Here

        Sheet sheet = wb.getSheetAt(0);


        // go through all formula cells
        for (int rInd = 2; rInd <= rowMax; rInd++) {
            Row row = sheet.getRow(rInd);

            for (int cInd = 1; cInd <= 12; cInd++) {
                Cell cell = row.getCell(cInd);
                String formula = cell.getCellFormula();
                CellReference ref = new CellReference(cell);

                //simulate correct answer
                String correct = "$A" + (rInd + 1) + "*" + columns[cInd] + "$2";
View Full Code Here

     * Vertically aligned text
     */
    public void test49524() throws Exception {
       HSSFWorkbook wb = openSample("49524.xls");
       Sheet s = wb.getSheetAt(0);
       Row r = s.getRow(0);
       Cell rotated = r.getCell(0);
       Cell normal = r.getCell(1);
      
       // Check the current ones
       assertEquals(0, normal.getCellStyle().getRotation());
       assertEquals(0xff, rotated.getCellStyle().getRotation());
      
       // Add a new style, also rotated
       CellStyle cs = wb.createCellStyle();
       cs.setRotation((short)0xff);
       Cell nc = r.createCell(2);
       nc.setCellValue("New Rotated Text");
       nc.setCellStyle(cs);
       assertEquals(0xff, nc.getCellStyle().getRotation());
      
       // Write out and read back
       wb = writeOutAndReadBack(wb);
      
       // Re-check
       s = wb.getSheetAt(0);
       r = s.getRow(0);
       rotated = r.getCell(0);
       normal = r.getCell(1);
       nc = r.getCell(2);
      
       assertEquals(0, normal.getCellStyle().getRotation());
       assertEquals(0xff, rotated.getCellStyle().getRotation());
       assertEquals(0xff, nc.getCellStyle().getRotation());
    }
View Full Code Here

 
    @Override
    protected void exportCells(DataTable table, Object document) {
        Sheet sheet = (Sheet) document;
        int sheetRowIndex = sheet.getLastRowNum() + 1;
        Row row = sheet.createRow(sheetRowIndex);
       
        for (UIColumn col : table.getColumns()) {
            if (col instanceof DynamicColumn) {
                ((DynamicColumn) col).applyStatelessModel();
            }
View Full Code Here

        }
    }
   
  protected void addColumnFacets(DataTable table, Sheet sheet, ColumnType columnType) {
        int sheetRowIndex = columnType.equals(ColumnType.HEADER) ? 0 : (sheet.getLastRowNum() + 1);
        Row rowHeader = sheet.createRow(sheetRowIndex);
       
        for (UIColumn col : table.getColumns()) {
            if (col instanceof DynamicColumn) {
                ((DynamicColumn) col).applyStatelessModel();
            }
View Full Code Here

    Element colgroup = table.appendElement("colgroup");
    int firstRow = sheet.getFirstRowNum();
    int lastRow = sheet.getLastRowNum();
    int maxColumns = 0;
    for(int i=firstRow;i<=lastRow;i++){
      Row row = sheet.getRow(i);
      if(row!=null){
//        int firstColumn = row.getFirstCellNum();
        int lastColumn = row.getLastCellNum();
        if(lastColumn>maxColumns){
          maxColumns = lastColumn;
        }
      }
    }
View Full Code Here

    }
    int firstRow = sheet.getFirstRowNum();
    int lastRow = sheet.getLastRowNum();
//    int maxColumns = 0;
    for(int i=0;i<=lastRow;i++){
      Row row = sheet.getRow(i);
      if(row!=null){
//        int firstColumn = row.getFirstCellNum();
        Element tr = table.appendElement("tr");
        if(row.getHeightInPoints()<DEFAULT_ROW_HEIGHT){
          tr.attr("height",String.valueOf(pointsToPixels(DEFAULT_ROW_HEIGHT-6))+"px");
        }else{
          tr.attr("height",String.valueOf(pointsToPixels(row.getHeightInPoints()))+"px");
        }
      }else{
        Element tr = table.appendElement("tr");
        tr.attr("height",String.valueOf(pointsToPixels(DEFAULT_ROW_HEIGHT))+"px");
      }
View Full Code Here

        if(i<firstRow){//代表是空Cell,直接添加一个空的td
          for(int j=0;j<totalColumns;j++){
            tr.appendElement("td");
          }
        }else{
          Row row = sheet.getRow(i);
          if(row==null){
            for(int j=0;j<totalColumns;j++){
              tr.appendElement("td");
            }
          }else{
            int firstColumn = row.getFirstCellNum();
            int lastColumn = row.getLastCellNum();
            for(int j=0;j<totalColumns;j++){
              if(j<firstColumn){
                tr.appendElement("td");
              }else{
                Cell cell = row.getCell(j);
                Element td = tr.appendElement("td");
                if(cell!=null){
                  if(cell.getCellType()==Cell.CELL_TYPE_FORMULA){
                    td.attr("formula","="+cell.getCellFormula());
                  }else if(cell.getCellType()==Cell.CELL_TYPE_BLANK){
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Row

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.