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

ICustomViews

Interface ICustomViews

All Superinterfaces:
Iterable<ICustomView>

public interface ICustomViews extends Iterable<ICustomView>
自定义工作簿视图的集合。

此接口表示 Workbook.getCustomViews() 返回的集合。集合中的每一项都是 ICustomView,用于存储工作簿自定义视图,并且可以按名称检索、添加到工作簿或按顺序迭代。


 worksheet.getPageSetup().setPrintArea("$A$1:$C$10");
 ICustomViews customViews = workbook.getCustomViews();
 customViews.add("PrintView", true, false);
 ICustomView customView = customViews.get("PrintView");
 customView.show();
 
  • Method Details

    • getCount

      int getCount()
      获取集合中自定义视图的数量。

      此方法返回当前可用的 ICustomView 对象数量,这些对象来自 Workbook.getCustomViews()。

      
       worksheet.getPageSetup().setPrintArea("$A$1:$C$10");
       workbook.getCustomViews().add("PrintView", true, false);
       workbook.getCustomViews().add("HiddenRows", false, true);
       int count = workbook.getCustomViews().getCount();
       
      Returns:
      集合中自定义视图的数量。
    • get

      ICustomView get(String viewName)
      获取具有指定名称的 ICustomView 对象。

      使用此方法可以检索先前添加到此集合的自定义工作簿视图,然后通过调用 ICustomView.show() 应用它。

      
       workbook.getCustomViews().add("PrintSetting", true, false);
       ICustomView customView = workbook.getCustomViews().get("PrintSetting");
       customView.show();
       
      Parameters:
      viewName - 集合中自定义视图的名称。
      Returns:
      具有指定名称的 ICustomView 对象。
    • add

      ICustomView add(String viewName, boolean printSettings, boolean rowColSettings)
      基于当前工作簿视图状态创建自定义视图。

      自定义视图捕获工作簿中所有工作表的当前视图状态。如果已存在同名自定义视图,则现有自定义视图将被替换。当工作簿包含表格或数据透视表时,无法添加自定义视图。

      
       worksheet.getPageSetup().setPrintArea("$A$1:$C$10");
       ICustomView customView = workbook.getCustomViews().add("PrintView", true, false);
       customView.show();
       
      Parameters:
      viewName - 自定义视图的名称。不得为 null、空或空白。
      printSettings - true 表示在自定义视图中包含打印设置;否则为 false。
      rowColSettings - true 表示在自定义视图中包含隐藏的行和列设置(包括筛选信息);否则为 false。
      Returns:
      新创建的 ICustomView。
      Throws:
      IllegalArgumentException - 如果 viewName 为 null、空或空白,或者工作簿包含表格或数据透视表。