Examples of CTStylesheet


Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
  protected void readFrom(InputStream is) throws IOException {
    try {
      doc = StyleSheetDocument.Factory.parse(is);

            CTStylesheet styleSheet = doc.getStyleSheet();

            // Grab all the different bits we care about
      CTNumFmts ctfmts = styleSheet.getNumFmts();
            if( ctfmts != null){
                for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
                    numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
                }
            }

            CTFonts ctfonts = styleSheet.getFonts();
            if(ctfonts != null){
        int idx = 0;
        for (CTFont font : ctfonts.getFontArray()) {
           // Create the font and save it. Themes Table supplied later
          XSSFFont f = new XSSFFont(font, idx);
          fonts.add(f);
          idx++;
        }
      }
            CTFills ctfills = styleSheet.getFills();
            if(ctfills != null){
                for (CTFill fill : ctfills.getFillArray()) {
                    fills.add(new XSSFCellFill(fill));
                }
            }

            CTBorders ctborders = styleSheet.getBorders();
            if(ctborders != null) {
                for (CTBorder border : ctborders.getBorderArray()) {
                    borders.add(new XSSFCellBorder(border));
                }
            }

            CTCellXfs cellXfs = styleSheet.getCellXfs();
            if(cellXfs != null) xfs.addAll(Arrays.asList(cellXfs.getXfArray()));

            CTCellStyleXfs cellStyleXfs = styleSheet.getCellStyleXfs();
            if(cellStyleXfs != null) styleXfs.addAll(Arrays.asList(cellStyleXfs.getXfArray()));

            CTDxfs styleDxfs = styleSheet.getDxfs();
      if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));

    } catch (XmlException e) {
      throw new IOException(e.getLocalizedMessage());
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);

    // Work on the current one
    // Need to do this, as we don't handle
    //  all the possible entries yet
        CTStylesheet styleSheet = doc.getStyleSheet();

    // Formats
    CTNumFmts formats = CTNumFmts.Factory.newInstance();
    formats.setCount(numberFormats.size());
    for (Entry<Integer, String> fmt : numberFormats.entrySet()) {
      CTNumFmt ctFmt = formats.addNewNumFmt();
      ctFmt.setNumFmtId(fmt.getKey());
      ctFmt.setFormatCode(fmt.getValue());
    }
    styleSheet.setNumFmts(formats);

    int idx;
    // Fonts
    CTFonts ctFonts = CTFonts.Factory.newInstance();
    ctFonts.setCount(fonts.size());
    CTFont[] ctfnt = new CTFont[fonts.size()];
    idx = 0;
    for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
    ctFonts.setFontArray(ctfnt);
    styleSheet.setFonts(ctFonts);

    // Fills
    CTFills ctFills = CTFills.Factory.newInstance();
    ctFills.setCount(fills.size());
    CTFill[] ctf = new CTFill[fills.size()];
    idx = 0;
    for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
    ctFills.setFillArray(ctf);
    styleSheet.setFills(ctFills);

    // Borders
    CTBorders ctBorders = CTBorders.Factory.newInstance();
    ctBorders.setCount(borders.size());
    CTBorder[] ctb = new CTBorder[borders.size()];
    idx = 0;
    for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
    ctBorders.setBorderArray(ctb);
    styleSheet.setBorders(ctBorders);

    // Xfs
    if(xfs.size() > 0) {
      CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
      ctXfs.setCount(xfs.size());
      ctXfs.setXfArray(
          xfs.toArray(new CTXf[xfs.size()])
      );
      styleSheet.setCellXfs(ctXfs);
    }

    // Style xfs
    if(styleXfs.size() > 0) {
      CTCellStyleXfs ctSXfs = CTCellStyleXfs.Factory.newInstance();
      ctSXfs.setCount(styleXfs.size());
      ctSXfs.setXfArray(
          styleXfs.toArray(new CTXf[styleXfs.size()])
      );
      styleSheet.setCellStyleXfs(ctSXfs);
    }

    // Style dxfs
    if(dxfs.size() > 0) {
      CTDxfs ctDxfs = CTDxfs.Factory.newInstance();
      ctDxfs.setCount(dxfs.size());
      ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
      );
      styleSheet.setDxfs(ctDxfs);
    }

    // Save
    doc.save(out, options);
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet


public class TestXSSFBorder extends TestCase {
 
  public void testGetBorderStyle() {
    CTStylesheet stylesheet = CTStylesheet.Factory.newInstance();
    CTBorder border = stylesheet.addNewBorders().addNewBorder();
    CTBorderPr top = border.addNewTop();
    CTBorderPr right = border.addNewRight();
    CTBorderPr bottom = border.addNewBottom();
    top.setStyle(STBorderStyle.DASH_DOT);
    right.setStyle(STBorderStyle.NONE);
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
  protected void readFrom(InputStream is) throws IOException {
    try {
      doc = StyleSheetDocument.Factory.parse(is);

            CTStylesheet styleSheet = doc.getStyleSheet();

            // Grab all the different bits we care about
      CTNumFmts ctfmts = styleSheet.getNumFmts();
            if( ctfmts != null){
                for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
                    numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
                }
            }

            CTFonts ctfonts = styleSheet.getFonts();
            if(ctfonts != null){
        int idx = 0;
        for (CTFont font : ctfonts.getFontArray()) {
          XSSFFont f = new XSSFFont(font, idx);
          fonts.add(f);
          idx++;
        }
      }
            CTFills ctfills = styleSheet.getFills();
            if(ctfills != null){
                for (CTFill fill : ctfills.getFillArray()) {
                    fills.add(new XSSFCellFill(fill));
                }
            }

            CTBorders ctborders = styleSheet.getBorders();
            if(ctborders != null) {
                for (CTBorder border : ctborders.getBorderArray()) {
                    borders.add(new XSSFCellBorder(border));
                }
            }

            CTCellXfs cellXfs = styleSheet.getCellXfs();
            if(cellXfs != null) xfs.addAll(Arrays.asList(cellXfs.getXfArray()));

            CTCellStyleXfs cellStyleXfs = styleSheet.getCellStyleXfs();
            if(cellStyleXfs != null) styleXfs.addAll(Arrays.asList(cellStyleXfs.getXfArray()));

            CTDxfs styleDxfs = styleSheet.getDxfs();
      if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));

    } catch (XmlException e) {
      throw new IOException(e.getLocalizedMessage());
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);

    // Work on the current one
    // Need to do this, as we don't handle
    //  all the possible entries yet
        CTStylesheet styleSheet = doc.getStyleSheet();

    // Formats
    CTNumFmts formats = CTNumFmts.Factory.newInstance();
    formats.setCount(numberFormats.size());
    for (Entry<Integer, String> fmt : numberFormats.entrySet()) {
      CTNumFmt ctFmt = formats.addNewNumFmt();
      ctFmt.setNumFmtId(fmt.getKey());
      ctFmt.setFormatCode(fmt.getValue());
    }
    styleSheet.setNumFmts(formats);

    int idx;
    // Fonts
    CTFonts ctFonts = CTFonts.Factory.newInstance();
    ctFonts.setCount(fonts.size());
    CTFont[] ctfnt = new CTFont[fonts.size()];
    idx = 0;
    for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
    ctFonts.setFontArray(ctfnt);
    styleSheet.setFonts(ctFonts);

    // Fills
    CTFills ctFills = CTFills.Factory.newInstance();
    ctFills.setCount(fills.size());
    CTFill[] ctf = new CTFill[fills.size()];
    idx = 0;
    for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
    ctFills.setFillArray(ctf);
    styleSheet.setFills(ctFills);

    // Borders
    CTBorders ctBorders = CTBorders.Factory.newInstance();
    ctBorders.setCount(borders.size());
    CTBorder[] ctb = new CTBorder[borders.size()];
    idx = 0;
    for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
    ctBorders.setBorderArray(ctb);
    styleSheet.setBorders(ctBorders);

    // Xfs
    if(xfs.size() > 0) {
      CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
      ctXfs.setCount(xfs.size());
      ctXfs.setXfArray(
          xfs.toArray(new CTXf[xfs.size()])
      );
      styleSheet.setCellXfs(ctXfs);
    }

    // Style xfs
    if(styleXfs.size() > 0) {
      CTCellStyleXfs ctSXfs = CTCellStyleXfs.Factory.newInstance();
      ctSXfs.setCount(styleXfs.size());
      ctSXfs.setXfArray(
          styleXfs.toArray(new CTXf[styleXfs.size()])
      );
      styleSheet.setCellStyleXfs(ctSXfs);
    }

    // Style dxfs
    if(dxfs.size() > 0) {
      CTDxfs ctDxfs = CTDxfs.Factory.newInstance();
      ctDxfs.setCount(dxfs.size());
      ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
      );
      styleSheet.setDxfs(ctDxfs);
    }

    // Save
    doc.save(out, options);
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
  protected void readFrom(InputStream is) throws IOException {
    try {
      doc = StyleSheetDocument.Factory.parse(is);

            CTStylesheet styleSheet = doc.getStyleSheet();

            // Grab all the different bits we care about
      CTNumFmts ctfmts = styleSheet.getNumFmts();
            if( ctfmts != null){
                for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
                    numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
                }
            }

            CTFonts ctfonts = styleSheet.getFonts();
            if(ctfonts != null){
        int idx = 0;
        for (CTFont font : ctfonts.getFontArray()) {
           // Create the font and save it. Themes Table supplied later
          XSSFFont f = new XSSFFont(font, idx);
          fonts.add(f);
          idx++;
        }
      }
            CTFills ctfills = styleSheet.getFills();
            if(ctfills != null){
                for (CTFill fill : ctfills.getFillArray()) {
                    fills.add(new XSSFCellFill(fill));
                }
            }

            CTBorders ctborders = styleSheet.getBorders();
            if(ctborders != null) {
                for (CTBorder border : ctborders.getBorderArray()) {
                    borders.add(new XSSFCellBorder(border));
                }
            }

            CTCellXfs cellXfs = styleSheet.getCellXfs();
            if(cellXfs != null) xfs.addAll(Arrays.asList(cellXfs.getXfArray()));

            CTCellStyleXfs cellStyleXfs = styleSheet.getCellStyleXfs();
            if(cellStyleXfs != null) styleXfs.addAll(Arrays.asList(cellStyleXfs.getXfArray()));

            CTDxfs styleDxfs = styleSheet.getDxfs();
      if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));

    } catch (XmlException e) {
      throw new IOException(e.getLocalizedMessage());
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);

    // Work on the current one
    // Need to do this, as we don't handle
    //  all the possible entries yet
        CTStylesheet styleSheet = doc.getStyleSheet();

    // Formats
    CTNumFmts formats = CTNumFmts.Factory.newInstance();
    formats.setCount(numberFormats.size());
    for (Entry<Integer, String> fmt : numberFormats.entrySet()) {
      CTNumFmt ctFmt = formats.addNewNumFmt();
      ctFmt.setNumFmtId(fmt.getKey());
      ctFmt.setFormatCode(fmt.getValue());
    }
    styleSheet.setNumFmts(formats);

    int idx;
    // Fonts
    CTFonts ctFonts = CTFonts.Factory.newInstance();
    ctFonts.setCount(fonts.size());
    CTFont[] ctfnt = new CTFont[fonts.size()];
    idx = 0;
    for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
    ctFonts.setFontArray(ctfnt);
    styleSheet.setFonts(ctFonts);

    // Fills
    CTFills ctFills = CTFills.Factory.newInstance();
    ctFills.setCount(fills.size());
    CTFill[] ctf = new CTFill[fills.size()];
    idx = 0;
    for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
    ctFills.setFillArray(ctf);
    styleSheet.setFills(ctFills);

    // Borders
    CTBorders ctBorders = CTBorders.Factory.newInstance();
    ctBorders.setCount(borders.size());
    CTBorder[] ctb = new CTBorder[borders.size()];
    idx = 0;
    for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
    ctBorders.setBorderArray(ctb);
    styleSheet.setBorders(ctBorders);

    // Xfs
    if(xfs.size() > 0) {
      CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
      ctXfs.setCount(xfs.size());
      ctXfs.setXfArray(
          xfs.toArray(new CTXf[xfs.size()])
      );
      styleSheet.setCellXfs(ctXfs);
    }

    // Style xfs
    if(styleXfs.size() > 0) {
      CTCellStyleXfs ctSXfs = CTCellStyleXfs.Factory.newInstance();
      ctSXfs.setCount(styleXfs.size());
      ctSXfs.setXfArray(
          styleXfs.toArray(new CTXf[styleXfs.size()])
      );
      styleSheet.setCellStyleXfs(ctSXfs);
    }

    // Style dxfs
    if(dxfs.size() > 0) {
      CTDxfs ctDxfs = CTDxfs.Factory.newInstance();
      ctDxfs.setCount(dxfs.size());
      ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
      );
      styleSheet.setDxfs(ctDxfs);
    }

    // Save
    doc.save(out, options);
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
  protected void readFrom(InputStream is) throws IOException {
    try {
      doc = StyleSheetDocument.Factory.parse(is);

            CTStylesheet styleSheet = doc.getStyleSheet();

            // Grab all the different bits we care about
      CTNumFmts ctfmts = styleSheet.getNumFmts();
            if( ctfmts != null){
                for (CTNumFmt nfmt : ctfmts.getNumFmtArray()) {
                    numberFormats.put((int)nfmt.getNumFmtId(), nfmt.getFormatCode());
                }
            }

            CTFonts ctfonts = styleSheet.getFonts();
            if(ctfonts != null){
        int idx = 0;
        for (CTFont font : ctfonts.getFontArray()) {
           // Create the font and save it. Themes Table supplied later
          XSSFFont f = new XSSFFont(font, idx);
          fonts.add(f);
          idx++;
        }
      }
            CTFills ctfills = styleSheet.getFills();
            if(ctfills != null){
                for (CTFill fill : ctfills.getFillArray()) {
                    fills.add(new XSSFCellFill(fill));
                }
            }

            CTBorders ctborders = styleSheet.getBorders();
            if(ctborders != null) {
                for (CTBorder border : ctborders.getBorderArray()) {
                    borders.add(new XSSFCellBorder(border));
                }
            }

            CTCellXfs cellXfs = styleSheet.getCellXfs();
            if(cellXfs != null) xfs.addAll(Arrays.asList(cellXfs.getXfArray()));

            CTCellStyleXfs cellStyleXfs = styleSheet.getCellStyleXfs();
            if(cellStyleXfs != null) styleXfs.addAll(Arrays.asList(cellStyleXfs.getXfArray()));

            CTDxfs styleDxfs = styleSheet.getDxfs();
      if(styleDxfs != null) dxfs.addAll(Arrays.asList(styleDxfs.getDxfArray()));

    } catch (XmlException e) {
      throw new IOException(e.getLocalizedMessage());
    }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet

    XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS);

    // Work on the current one
    // Need to do this, as we don't handle
    //  all the possible entries yet
        CTStylesheet styleSheet = doc.getStyleSheet();

    // Formats
    CTNumFmts formats = CTNumFmts.Factory.newInstance();
    formats.setCount(numberFormats.size());
    for (Entry<Integer, String> fmt : numberFormats.entrySet()) {
      CTNumFmt ctFmt = formats.addNewNumFmt();
      ctFmt.setNumFmtId(fmt.getKey());
      ctFmt.setFormatCode(fmt.getValue());
    }
    styleSheet.setNumFmts(formats);

    int idx;
    // Fonts
    CTFonts ctFonts = CTFonts.Factory.newInstance();
    ctFonts.setCount(fonts.size());
    CTFont[] ctfnt = new CTFont[fonts.size()];
    idx = 0;
    for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
    ctFonts.setFontArray(ctfnt);
    styleSheet.setFonts(ctFonts);

    // Fills
    CTFills ctFills = CTFills.Factory.newInstance();
    ctFills.setCount(fills.size());
    CTFill[] ctf = new CTFill[fills.size()];
    idx = 0;
    for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
    ctFills.setFillArray(ctf);
    styleSheet.setFills(ctFills);

    // Borders
    CTBorders ctBorders = CTBorders.Factory.newInstance();
    ctBorders.setCount(borders.size());
    CTBorder[] ctb = new CTBorder[borders.size()];
    idx = 0;
    for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
    ctBorders.setBorderArray(ctb);
    styleSheet.setBorders(ctBorders);

    // Xfs
    if(xfs.size() > 0) {
      CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
      ctXfs.setCount(xfs.size());
      ctXfs.setXfArray(
          xfs.toArray(new CTXf[xfs.size()])
      );
      styleSheet.setCellXfs(ctXfs);
    }

    // Style xfs
    if(styleXfs.size() > 0) {
      CTCellStyleXfs ctSXfs = CTCellStyleXfs.Factory.newInstance();
      ctSXfs.setCount(styleXfs.size());
      ctSXfs.setXfArray(
          styleXfs.toArray(new CTXf[styleXfs.size()])
      );
      styleSheet.setCellStyleXfs(ctSXfs);
    }

    // Style dxfs
    if(dxfs.size() > 0) {
      CTDxfs ctDxfs = CTDxfs.Factory.newInstance();
      ctDxfs.setCount(dxfs.size());
      ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
      );
      styleSheet.setDxfs(ctDxfs);
    }

    // Save
    doc.save(out, options);
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet


public class TestXSSFBorder extends TestCase {
 
  public void testGetBorderStyle() {
    CTStylesheet stylesheet = CTStylesheet.Factory.newInstance();
    CTBorder border = stylesheet.addNewBorders().addNewBorder();
    CTBorderPr top = border.addNewTop();
    CTBorderPr right = border.addNewRight();
    CTBorderPr bottom = border.addNewBottom();
   
    top.setStyle(STBorderStyle.DASH_DOT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.