[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

IDocumentPropertyCollection

Interface IDocumentPropertyCollection

All Known Subinterfaces:
IBuiltInDocumentPropertyCollection, ICustomDocumentPropertyCollection

public interface IDocumentPropertyCollection
表示文档属性的集合。

此接口提供对工作簿中内置和自定义文档属性的访问。使用它可以按名称或索引检索属性,检查属性是否存在,获取属性数量,或从集合中移除属性。


 ICustomDocumentPropertyCollection customProperties = workbook.getCustomDocumentProperties();
 customProperties.add("Department", "Sales");
 IDocumentPropertyCollection properties = customProperties;
 IDocumentProperty property = properties.get("Department");
 
  • Method Details

    • getCount

      int getCount()
      获取集合中的文档属性数量。

      此方法返回此 IDocumentPropertyCollection 中包含的当前属性数量。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       properties.add("Region", "North");
       int count = properties.getCount();
       
      Returns:
      集合中的文档属性数量。
    • get

      返回具有指定名称的 IDocumentProperty 对象。

      使用此方法可以按名称从集合中检索文档属性。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       IDocumentProperty property = properties.get("Department");
       
      Parameters:
      name - 集合中元素的名称。
      Returns:
      具有指定名称的 IDocumentProperty 对象。
    • get

      IDocumentProperty get(int index)
      获取集合中指定索引处的 IDocumentProperty 对象。

      使用此方法可以按文档属性在 IDocumentPropertyCollection(例如自定义文档属性集合)中的位置检索该属性。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       IDocumentProperty property = properties.get(0);
       String name = property.getName();
       
      Parameters:
      index - 文档属性在集合中的索引。
      Returns:
      指定索引处的 IDocumentProperty 对象。
    • contains

      boolean contains(String name)
      确定此集合中是否存在具有指定名称的文档属性。
      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       boolean contains = properties.contains("Department");
       
      Parameters:
      name - 要查找的文档属性的名称。
      Returns:
      如果此集合中存在具有指定名称的文档属性,则为 true;否则为 false。
    • clear

      void clear()
      从集合中移除所有属性。

      使用此方法可以在添加一组新属性之前清空文档属性集合。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       properties.add("Quarter", "Q2");
       properties.clear();
       
    • indexOf

      int indexOf(String name)
      按名称获取属性的索引。

      属性名称比较不区分大小写。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       int index = properties.indexOf("department");
       
      Parameters:
      name - 属性的不区分大小写的名称。
      Returns:
      属性的从零开始的索引。如果未找到该属性,则返回负值。
    • remove

      void remove(String name)
      从集合中移除具有指定名称的属性。

      属性名称比较不区分大小写。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       properties.add("Region", "North");
       properties.remove("department");
       
      Parameters:
      name - 要移除的属性的不区分大小写的名称。
    • removeAt

      void removeAt(int index)
      移除指定的从零开始的索引处的属性。

      使用此方法可以按文档属性在集合中的位置而不是按名称移除文档属性。

      
       ICustomDocumentPropertyCollection properties = workbook.getCustomDocumentProperties();
       properties.add("Department", "Sales");
       properties.add("Region", "North");
       properties.removeAt(0);
       
      Parameters:
      index - 要移除的属性的从零开始的索引。