Package jxl.write

Examples of jxl.write.WritableSheet


    Workbook workbook = Workbook.getWorkbook(is);

    String tempFName = defaultValue.getSavingFileName(instance);
    WritableWorkbook copy = Workbook.createWorkbook(new File(tempFName), workbook);
 
    WritableSheet sheets[] = copy.getSheets();
//System.out.println("  ExcelSheetActivity:getWIHAddress: start parsing file");

    for(int i=0; i<sheets.length; i++){
      WritableSheet sheet = sheets[i];
       
      for(int row = 0; row < sheet.getRows(); row++){
        boolean newRowInserted=false;
       
        for(int col = 0; col < sheet.getColumns(); col++){           
          WritableCell cell = sheet.getWritableCell(col,row);
         
          if (cell.getType() == CellType.LABEL)
          {
            Label l = (Label) cell;       
            String expression = l.getString();
           
            if(expression.startsWith("<%=+")){
//System.out.println("expression:"+expression);
             
              if(!newRowInserted){
                newRowInserted = true;
                sheet.insertRow(row);
              }
              //l.setString(expression);
/*
                WritableCell existingCell = sheet.getWritableCell(col,row);
                Label ecl = (Label) existingCell;
                ecl.setString(               
                  EMailActivity.parseContent(expression, this, instance).toString()
                );*/
             
              jxl.format.CellFormat style = l.getCellFormat();
              WritableCell label = new Label(col,row, definition.evaluateContent(instance, expression).toString(), style);
              sheet.addCell(label);
             
            }else
            if(expression.indexOf("<%=") > -1 || expression.indexOf("<%=*") > -1){ //if the expression contains any value need to evaluate.
//System.out.println("expression:"+expression);
              l.setString(
                definition.evaluateContent( instance, expression).toString()
              );
//System.out.println("evaluated:"+l.getString());
            }else
            if(expression.startsWith("<%->")){
              l.setString("");
            }else
            if(expression.startsWith("<%<-")){
              WritableCell leftCell = sheet.getWritableCell(col-1,row);
              Label lcl = (Label) leftCell;         
              lcl.setString(
                definition.evaluateContent(instance, expression).toString()
              );
             
View Full Code Here


  {
    ArrayList<KeyString> idflist=new ArrayList<KeyString>();
   
    System.out.println("Saving "+file.getName());
    WritableWorkbook workbook = Workbook.createWorkbook(file);
    WritableSheet header = workbook.createSheet("Experimental setup", 0);
    addHeader(header,tests);
    if(summary.contains("all")||summary.contains("performance"))
    {
      System.out.println("Generating performance summary sheet");
      WritableSheet sheet = workbook.createSheet("Performance summary", workbook.getNumberOfSheets());
      addPerformanceSheet(sheet,tests,time);
    }
    if(summary.contains("all")||summary.contains("disambiguation"))
    {
      System.out.println("Generating disambiguation summary sheet");
      WritableSheet  sheet = workbook.createSheet("Words leading to disambiguation", workbook.getNumberOfSheets());
      addDisambiguationSheet(sheet,tests);
    }
    if(summary.contains("all")||summary.contains("words"))
    {
      System.out.println("Problem summary sheet");
      WritableSheet docs = workbook.createSheet("Disambiguated words", workbook.getNumberOfSheets());
      addProblemSheet(docs,tests);
    }
    if(summary.contains("all")||summary.contains("overlap"))
    {
      System.out.println("Generating overlap summary sheet");
      WritableSheet sheet = workbook.createSheet("Overlap by IDF summary", workbook.getNumberOfSheets());
      if(idflist.size()==0)
        XLSWriter.retrieveIDFs(idflist, tests);
      addOverlapSheet(sheet, tests,idflist);
    }
    if(summary.contains("all")||summary.contains("sense"))
    {
      System.out.println("Generating sense stats sheet");
      WritableSheet sheet = workbook.createSheet("Algorithm behavior", workbook.getNumberOfSheets());
      addMiscSheet(sheet, tests);
    }
    if(detail.contains("all")||detail.contains("performance"))
    {
      System.out.println("Generating performance detail sheet");
      WritableSheet sheet = workbook.createSheet("Performance detail", workbook.getNumberOfSheets());
      addPerformanceDetailSheet(sheet,tests);
    }
    if(detail.contains("all")||detail.contains("disambiguation"))
    {
      System.out.println("Generating disambiguation detail sheet");
      WritableSheet  sheet = workbook.createSheet("Disambiguation detail", workbook.getNumberOfSheets());
      if(idflist.size()==0)
        XLSWriter.retrieveIDFs(idflist, tests);
      addDisambiguationDetailSheet(sheet,tests,idflist);
    }
    if(detail.contains("all")||detail.contains("words"))
    {
      System.out.println("Generating problem detail sheet");
      WritableSheet docs = workbook.createSheet("Problem detail", workbook.getNumberOfSheets());
      if(idflist.size()==0)
        XLSWriter.retrieveIDFs(idflist, tests);
      addProblemDetailSheet(docs,tests,idflist);
    }
    if(detail.contains("overlap"))
    {
      System.out.println("Generating overlap detail sheet");
      WritableSheet sheet = workbook.createSheet("Overlap detail", workbook.getNumberOfSheets());
      addOverlapDetailSheet(sheet,tests);
    }
   
   
    if(detail.contains("all")||detail.contains("sense"))
    {
      System.out.println("Generating sense detail sheet");
      WritableSheet sheet = workbook.createSheet("Disambiguation by sense number", workbook.getNumberOfSheets());
      addSenseSheet(sheet,tests);
    }   
    workbook.write();
    workbook.close();
    System.out.println(file.getName()+" saved");
View Full Code Here

        } catch (IOException ex) {
            Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
        }


        WritableSheet sheetCoordenadas = libroTrabajoSalida.getSheet(this.hojaHeuristica);
        //Primero completamos la nueva columna
        for (int i = 0; i < limiteHeuristica.getFilas() + 1; i++) {
            Number heuristicaCol = new Number(limiteHeuristica.getColumnas() + 1, i + 1, 0);
            try {
                sheetCoordenadas.addCell(heuristicaCol);
            } catch (WriteException ex) {
                System.out.println("Aqui es el error");
                Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        //Segundo completamos la nueva fila
        for (int i = 0; i < limiteHeuristica.getColumnas() + 1; i++) {
            Number heuristicaFila = new Number(i + 1, limiteHeuristica.getFilas() + 1, 0);
            try {
                sheetCoordenadas.addCell(heuristicaFila);
            } catch (WriteException ex) {
                System.out.println("Aqui es el error");
                Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
View Full Code Here

        } catch (IOException ex) {
            Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
        }


        WritableSheet sheetCoordenadas = libroTrabajoSalida.getSheet(this.hojaCoordenadasPuntos);

        Number coordenadaXCelda = new Number(1, limiteCoordenadas.getFilas() + 1, coordenadaX);
        Number coordenadaYCelda = new Number(2, limiteCoordenadas.getFilas() + 1, coordenadaY);

        try {
            sheetCoordenadas.addCell(coordenadaXCelda);
            sheetCoordenadas.addCell(coordenadaYCelda);
        } catch (WriteException ex) {
            System.out.println("Aqui es el error");
            Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

            libroTrabajo.close();
        } catch (IOException ex) {
            Logger.getLogger(ArchivoExcelBaseConocimiento.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (tipo == ArchivoExcelBaseConocimiento.REGLAS) {
            WritableSheet sheetReglas = libroTrabajoSalida.getSheet(this.hojaConfiguraciones);
            //recordar que primero son las columnas y luego filas
            WritableCell celdaFilas = sheetReglas.getWritableCell(1, 3);
            WritableCell celdaColumnas = sheetReglas.getWritableCell(2, 3);

            if (celdaFilas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaFilas;
                n.setValue(numeroFilas);
            }
            if (celdaColumnas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaColumnas;
                n.setValue(numeroColumnas);
            }
        } else if (tipo == ArchivoExcelBaseConocimiento.NOMBRESPUNTOS) {
            WritableSheet sheetReglas = libroTrabajoSalida.getSheet(this.hojaConfiguraciones);
            //recordar que primero son las columnas y luego filas
            WritableCell celdaFilas = sheetReglas.getWritableCell(1, 2);
            WritableCell celdaColumnas = sheetReglas.getWritableCell(2, 2);

            if (celdaFilas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaFilas;
                n.setValue(numeroFilas);
            }
            if (celdaColumnas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaColumnas;
                n.setValue(numeroColumnas);
            }
        } else if (tipo == ArchivoExcelBaseConocimiento.HEURISTICA) {
            WritableSheet sheetReglas = libroTrabajoSalida.getSheet(this.hojaConfiguraciones);
            //recordar que primero son las columnas y luego filas
            WritableCell celdaFilas = sheetReglas.getWritableCell(1, 1);
            WritableCell celdaColumnas = sheetReglas.getWritableCell(2, 1);

            if (celdaFilas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaFilas;
                n.setValue(numeroFilas);
            }
            if (celdaColumnas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaColumnas;
                n.setValue(numeroColumnas);
            }
        } else if (tipo == ArchivoExcelBaseConocimiento.COORDENADASPUNTOS) {
            WritableSheet sheetReglas = libroTrabajoSalida.getSheet(this.hojaConfiguraciones);
            //recordar que primero son las columnas y luego filas
            WritableCell celdaFilas = sheetReglas.getWritableCell(1, 0);
            WritableCell celdaColumnas = sheetReglas.getWritableCell(2, 0);

            if (celdaFilas.getType() == CellType.NUMBER) {
                Number n = (Number) celdaFilas;
                n.setValue(numeroFilas);
            }
View Full Code Here

      protected void buildExcelDocument(Map model,
          WritableWorkbook wb,
          HttpServletRequest request,
          HttpServletResponse response)
          throws Exception {
        WritableSheet sheet = wb.createSheet("Test Sheet", 0);

        // test all possible permutation of row or column not existing
        sheet.addCell(new Label(2, 4, "Test Value"));
        sheet.addCell(new Label(2, 3, "Test Value"));
        sheet.addCell(new Label(3, 4, "Test Value"));
        sheet.addCell(new Label(2, 4, "Test Value"));
      }
    };

    excelView.render(new HashMap(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    assertEquals("Test Sheet", wb.getSheet(0).getName());
    Sheet sheet = wb.getSheet("Test Sheet");
    Cell cell = sheet.getCell(2, 4);
    assertEquals("Test Value", cell.getContents());
  }
View Full Code Here

      protected void buildExcelDocument(Map model,
          WritableWorkbook wb,
          HttpServletRequest request,
          HttpServletResponse response)
          throws Exception {
        WritableSheet sheet = wb.getSheet("Sheet1");

        // test all possible permutation of row or column not existing
        sheet.addCell(new Label(2, 4, "Test Value"));
        sheet.addCell(new Label(2, 3, "Test Value"));
        sheet.addCell(new Label(3, 4, "Test Value"));
        sheet.addCell(new Label(2, 4, "Test Value"));
      }
    };

    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template", cell.getContents());
  }
View Full Code Here

      protected void buildExcelDocument(Map model,
          WritableWorkbook wb,
          HttpServletRequest request,
          HttpServletResponse response)
          throws Exception {
        WritableSheet sheet = wb.getSheet("Sheet1");

        // test all possible permutation of row or column not existing
        sheet.addCell(new Label(2, 4, "Test Value"));
        sheet.addCell(new Label(2, 3, "Test Value"));
        sheet.addCell(new Label(3, 4, "Test Value"));
        sheet.addCell(new Label(2, 4, "Test Value"));
      }
    };

    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template American English", cell.getContents());
  }
View Full Code Here

      protected void buildExcelDocument(Map model,
          WritableWorkbook wb,
          HttpServletRequest request,
          HttpServletResponse response)
          throws Exception {
        WritableSheet sheet = wb.getSheet("Sheet1");

        // test all possible permutation of row or column not existing
        sheet.addCell(new Label(2, 4, "Test Value"));
        sheet.addCell(new Label(2, 3, "Test Value"));
        sheet.addCell(new Label(3, 4, "Test Value"));
        sheet.addCell(new Label(2, 4, "Test Value"));
      }
    };

    excelView.setApplicationContext(webAppCtx);
    excelView.setUrl("template");
    excelView.render(new HashMap(), request, response);

    Workbook wb = Workbook.getWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
    Sheet sheet = wb.getSheet("Sheet1");
    Cell cell = sheet.getCell(0, 0);
    assertEquals("Test Template auf Deutsch", cell.getContents());
  }
View Full Code Here

  private void exportEachBook(Book book, WritableWorkbook workbook) {
    List blist = book.getSheets();
    int i = 0;
    for (final Iterator it = blist.iterator(); it.hasNext();) {
      Sheet sheet = (Sheet) it.next();
      WritableSheet s = workbook.createSheet(sheet.getName(), i);
      exportEachSheet(sheet, s);
      i++;
    }
  }
View Full Code Here

TOP

Related Classes of jxl.write.WritableSheet

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.