简体   繁体   English

使用 uno 库以编程方式检查/取消检查 DataPilot 行字段的值

[英]Programmatically check/uncheck values of a DataPilot row field with the uno library

I want to be able to programmatically filter a Calc DataPilot (pivot table) with C# or Java.我希望能够以编程方式使用 C# 或 Java 过滤 Calc DataPilot(数据透视表)。

At the moment, I am able to do the below:目前,我可以执行以下操作:

  1. go to the sheet that contains the DataPilot go 到包含 DataPilot 的工作表
  2. get a reference to the DataPilot获取对 DataPilot 的引用
  3. Read its rowfields读取它的行字段
  4. Get a reference to the rowfield of interest获取对感兴趣的行字段的引用

Pending:待办的:

  1. By default, all values under the row field are checked.默认情况下,选中行字段下的所有值。 From that list, I want to be uncheck all of them and keep only specific.从该列表中,我想取消选中所有这些并仅保留特定内容。

Is this doable programmatically?这可以通过编程方式实现吗? If yes, what is the missing code to achieve this?如果是,实现此目的缺少的代码是什么?

Current code当前代码

XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)document; 
XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets(); 

//mSheetName is the name of the sheet that has the DataPilot I want to filter 
// get reference to the sheet that has my DataPilot 
XSpreadsheet sheet = (XSpreadsheet)xSpreadsheets.getByName(mSheetName).Value; 

//Get a reference to the DataPilot that I want to uncheck/check its row field values 
XDataPilotTablesSupplier xSupplier = (XDataPilotTablesSupplier)sheet; 
XDataPilotTables xSheetPilotTables = xSupplier.getDataPilotTables(); 

//mPivotTableName is the name of the DataPilot 
uno.Any xDPTableObj = xSheetPilotTables.getByName(mPivotTableName); 
XDataPilotTable xPilotTable = (XDataPilotTable)xDPTableObj.Value; 
XDataPilotDescriptor xDPDesc = (XDataPilotDescriptor)xPilotTable; 

// get available row fields
XNameAccess rowFields = (XNameAccess)xDPDesc.getRowFields(); 

//get the row field of interest 
//mFieldName is the name of the row field 
uno.Any xRowItemObj = rowFields.getByName(mFieldName); 

Example: if we assume the xRowItemObj has 2 checked values (eg 1 and 2) how do I keep value 1 checked only?示例:如果我们假设 xRowItemObj 有 2 个检查值(例如 1 和 2),我如何只检查值 1?

So far, any research in forums and libreOffice Documentation did not return a result.到目前为止,论坛和 libreOffice 文档中的任何研究都没有返回结果。 I am not even sure if it is doable我什至不确定它是否可行

Get the list of items from the row field.从行字段中获取项目列表。 Here is a Basic example that checks even-numbered boxes.这是一个检查偶数框的基本示例。

oRowItem = oDPTable.getRowFields().getByIndex(0)
oItems = oRowItem.getItems()
For i = 0 To oItems.getCount() - 1
    oItem = oItems.getByIndex(i)
    If (i Mod 2 = 0) Then
        oItem.setPropertyValue("IsHidden", False)
    Else
        oItem.setPropertyValue("IsHidden", True)
    End If
Next

If you haven't yet, be sure to use an introspection tool such as MRI .如果您还没有,请务必使用MRI等内省工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 选中/取消选中 CheckboxCell,单击一行 - GWT - Check/Uncheck CheckboxCell, onclick of a row - GWT 无法选中/取消选中CheckboxTableViewer的选定行上的复选框 - Cannot check/uncheck a checkbox on the selected row of a CheckboxTableViewer 复选框取消选中,列表视图的行值不会更新 - checkbox uncheck and row values of listview are not updated Android:如何在Java中以编程方式检查/取消选中RadioGroup中的RadioButton - Android: How to check/uncheck a RadioButton inside a RadioGroup programmatically in Java 选中/取消选中所有复选框并添加/减去值 - Check/uncheck all check box and add/subtract values 如何使用 Apache POI 获取数据透视表选项并取消选中显示选项卡中的“显示值行” - How to get the pivotTable options and uncheck the "show the Values row" in display tab using Apache POI 检查 ArrayList - IN A ROW - 的值是否相同 - Check if values of an ArrayList - IN A ROW - is the same ListView检查并取消选中项目逻辑 - ListView check and uncheck item logic 以编程方式检查Domino文档中的字段是Text还是TextList-可以吗? - Programmatically check if a field in a domino document is a Text or a TextList - is it possible? 选中jCheckBox1,取消选中jCheckBox2 - Check jCheckBox1, uncheck jCheckBox2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM