Package jxl.format

Examples of jxl.format.CellFormat


        bw.newLine();
        bw.write("    <name><![CDATA["+s.getName()+"]]></name>");
        bw.newLine();
     
        Cell[] row = null;
        CellFormat format = null;
        Font font = null;
     
        for (int i = 0 ; i < s.getRows() ; i++)
        {
          bw.write("    <row number=\"" + i + "\">");
          bw.newLine();
          row = s.getRow(i);

          for (int j = 0 ; j < row.length; j++)
          {
            // Remember that empty cells can contain format information
            if ((row[j].getType() != CellType.EMPTY) ||
                (row[j].getCellFormat() != null))
            {
              format = row[j].getCellFormat();
              bw.write("      <col number=\"" + j + "\">");
              bw.newLine();
              bw.write("        <data>");
              bw.write("<![CDATA["+row[j].getContents()+"]]>");
              bw.write("</data>");
              bw.newLine();    

              if (row[j].getCellFormat() != null)
              {
                bw.write("        <format wrap=\"" + format.getWrap() + "\"");
                bw.newLine();
                bw.write("                align=\"" +
                         format.getAlignment().getDescription() + "\"");
                bw.newLine();
                bw.write("                valign=\"" +
                         format.getVerticalAlignment().getDescription() + "\"");
                bw.newLine();
                bw.write("                orientation=\"" +
                         format.getOrientation().getDescription() + "\"");
                bw.write(">");
                bw.newLine();

                // The font information
                font = format.getFont();
                bw.write("          <font name=\"" + font.getName() + "\"");
                bw.newLine();
                bw.write("                point_size=\"" +
                         font.getPointSize() + "\"");
                bw.newLine();
                bw.write("                bold_weight=\"" +
                         font.getBoldWeight() + "\"");
                bw.newLine();
                bw.write("                italic=\"" + font.isItalic() + "\"");
                bw.newLine();
                bw.write("                underline=\"" +
                         font.getUnderlineStyle().getDescription() + "\"");
                bw.newLine();
                bw.write("                colour=\"" +
                         font.getColour().getDescription() + "\"");
                bw.newLine();
                bw.write("                script=\"" +
                         font.getScriptStyle().getDescription() + "\"");
                bw.write(" />");
                bw.newLine();


                // The cell background information
                if (format.getBackgroundColour() != Colour.DEFAULT_BACKGROUND ||
                    format.getPattern()          != Pattern.NONE)
                {
                  bw.write("          <background colour=\"" +
                           format.getBackgroundColour().getDescription() + "\"");
                  bw.newLine();
                  bw.write("                      pattern=\"" +
                           format.getPattern().getDescription() + "\"");
                  bw.write(" />");
                  bw.newLine();
                }


                // The cell border, if it has one
                if (format.getBorder(Border.TOP  != BorderLineStyle.NONE ||
                    format.getBorder(Border.BOTTOM) != BorderLineStyle.NONE ||
                    format.getBorder(Border.LEFT)   != BorderLineStyle.NONE ||
                    format.getBorder(Border.RIGHT!= BorderLineStyle.NONE)
                {
                 
                  bw.write("          <border top=\"" +
                           format.getBorder(Border.TOP).getDescription() + "\"");
                  bw.newLine();
                  bw.write("                  bottom=\"" +
                           format.getBorder(Border.BOTTOM).getDescription() +
                           "\"");
                  bw.newLine();
                  bw.write("                  left=\"" +
                           format.getBorder(Border.LEFT).getDescription() + "\"");
                  bw.newLine();
                  bw.write("                  right=\"" +
                           format.getBorder(Border.RIGHT).getDescription() + "\"");
                  bw.write(" />");
                  bw.newLine();
                }

                // The cell number/date format
                if (!format.getFormat().getFormatString().equals(""))
                {
                  bw.write("          <format_string string=\"");
                  bw.write(format.getFormat().getFormatString());
                  bw.write("\" />");
                  bw.newLine();
                }

                bw.write("        </format>");
View Full Code Here


    logger.info("Modifying...");

    WritableSheet sheet = w.getSheet("modified");
   
    WritableCell cell = null;
    CellFormat cf = null;
    Label l = null;
    WritableCellFeatures wcf = null;

    // Change the format of cell B4 to be emboldened
    cell = sheet.getWritableCell(1,3);
View Full Code Here

  /*
   * Import cell Format
   */
  private FormatImpl importCellStyle(jxl.Cell cell, int row, int col){
    FormatImpl zkFormat = new FormatImpl();
    CellFormat format = cell.getCellFormat();
    zkFormat.setFormatCodes(format.getFormat().getFormatString());
   
    /* text align */
    zkFormat.setTextVAlign(ExcelFormatHelper.getTextVAlign(format.getVerticalAlignment()));
    zkFormat.setTextHAlign(ExcelFormatHelper.getTextHAlign(format.getAlignment()));
   
    /* text indent */
    zkFormat.setTextIndent(format.getIndentation());
   
    /* Text Orient */
    //TODO System.out.println("TODO: Orein: "+format.getOrientation().getDescription());
    /* Text Angle*/
    zkFormat.setTextAngle(format.getOrientation().getValue());
   
    /* Text Control*/
    zkFormat.setTextWrap(format.getWrap());
    zkFormat.setTextShrinkToFit(format.isShrinkToFit());
    
    /* Text Direction*/
    //TODO
   
    jxl.format.Font font = format.getFont();
   
    /* font type */
    zkFormat.setFontType(font.getName());
   
    /* font style bold, italic */
    zkFormat.setFontStyle(ExcelFormatHelper.getFontStyle(font));
   
    /* font size */
    zkFormat.setFontSize(font.getPointSize());
   
    /* font underline */
    zkFormat.setFontUnderline(ExcelFormatHelper.getFontUnlineStyle(font.getUnderlineStyle()));
 
    /* font color*/
    zkFormat.setFontColor(ExcelFormatHelper.jxlColourToHex(font.getColour()));
   
    /* font strikethrough */
    zkFormat.setFontStrikethrough(font.isStruckout());
   
    /* font superscript*/
    zkFormat.setFontSuperscript(ExcelFormatHelper.isSuperscript(font.getScriptStyle()));
   
    /* font superscript*/
    zkFormat.setFontSubscript(ExcelFormatHelper.isSubscript(font.getScriptStyle()));
   
    /* Border */
    if(format.hasBorders()){
      zkFormat.setBorderBottom(
          ExcelFormatHelper.getBorderStyle(
              format.getBorderColour(Border.BOTTOM),
              format.getBorderLine(Border.BOTTOM)));
      //System.out.println(format.getBorderColour(Border.BOTTOM).getDescription());
      zkFormat.setBorderLeft(
          ExcelFormatHelper.getBorderStyle(
              format.getBorderColour(Border.LEFT),
              format.getBorderLine(Border.LEFT)));
     
      zkFormat.setBorderRight(
          ExcelFormatHelper.getBorderStyle(
              format.getBorderColour(Border.RIGHT),
              format.getBorderLine(Border.RIGHT)));
     
      zkFormat.setBorderTop(
          ExcelFormatHelper.getBorderStyle(
              format.getBorderColour(Border.TOP),
              format.getBorderLine(Border.TOP)));
    }
   
    /* Fill color hexidecimal #RRGGBB format (NONE means no color) */
    zkFormat.setFillColor(ExcelFormatHelper.jxlColourToHex(format.getBackgroundColour()));
   
    /* Pattern */
    //TODO pattern color
    zkFormat.setPatternStyle(ExcelFormatHelper.getPatternStyle(format.getPattern()));
   
    /* isLocked */
    zkFormat.setLocked(format.isLocked());
   
    /* isHidden */
    zkFormat.setHidden(cell.isHidden());
   
   
 
View Full Code Here

    return zkFormat;
  }
 
  /* import DateTimeCell format*/
  private FormatImpl importDateTimeCelFormat(FormatImpl zkFormat, jxl.DateCell cell , int row, int col){
    CellFormat cf = cell.getCellFormat();
    zkFormat.setFormatCodes(cf.getFormat().getFormatString());
    return zkFormat;
  }
View Full Code Here

    }
  }

  private void styleCell( String _styleName, WritableWorkbook _xwb, WritableSheet _xs, WritableCell _xc )
  {
    final CellFormat style = getCellStyle( _styleName );
    if (null != style) {
      _xc.setCellFormat( style );
    }
  }
View Full Code Here

TOP

Related Classes of jxl.format.CellFormat

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.