Examples of CTVector


Examples of org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.CTVector

  private void ranameSheetInAppXml(String oldsheetname, String name) {
      POIXMLProperties properties = getProperties(); //app.xml and custom.xml

    CTProperties ext = properties.getExtendedProperties().getUnderlyingProperties();
    CTVectorVariant vectorv = ext.getHeadingPairs();
    CTVector vector = vectorv.getVector();
    CTVariant[] variants = vector.getVariantArray();
    int sheetCount = -1;
    int nameCount = -1;
    for(int j = 0; j < variants.length; ++j) {
      final CTVariant variant = variants[j];
      if ((j & 1) == 0) { //string
        String key = variant.getLpstr();
        if ("Worksheets".equalsIgnoreCase(key)) {
          final CTVariant variant2 = variants[++j];
          sheetCount = variant2.getI4();
        } else if ("Named Ranges".equalsIgnoreCase(key)) {
          final CTVariant variant2 = variants[++j];
          nameCount = variant2.getI4();
        }
      }
    }
    if (sheetCount >= 0 && nameCount >= 0) {
      nameCount += sheetCount;
    }
    CTVectorLpstr vectorv2 = ext.getTitlesOfParts();
    CTVector vector2 = vectorv2.getVector();
    String[] lpstrs = vector2.getLpstrArray();
    int j = 0;
    for(; j < sheetCount; ++j) {
      final String sname = lpstrs[j];
      if (oldsheetname.equals(sname)) {
        vector2.setLpstrArray(j, name);
        j = sheetCount;
        break;
      }
    }
    final String o = SheetNameFormatter.format(oldsheetname);
    final String n = SheetNameFormatter.format(name);
    for(; j < nameCount; ++j) {
      final String refname = lpstrs[j];
      final String newrefname = refname.replace(o+"!", n+"!");
      if (!newrefname.equals(refname)) {
        vector2.setLpstrArray(j, newrefname);
      }
    }
  }
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.