Fail to show pivot item with no data

perco754

Board Regular
Joined
Apr 17, 2009
Messages
91
Hi,

Using: Win XP, VS 2010, Office 2003, .NET FW 3.5

I have a .NET app that reads exported data and sets up a PT in Excel using the Interop interface.

One thing that I fail to solve is how I could make a possible item (from the RowFields) with no data (= all cells are empty in the complete row of that particular item) to still appear in my PT view?

Here's the part of the code where I filter what data should be visible or not:

Excel.PivotItems _PivotItems = (Excel.PivotItems)_PivotField.PivotItems(omv);
foreach (Excel.PivotItem _PivotItem in _PivotItems)
{
if (string.Compare(_PivotItem.Name, "(blank)") != 0)
{
ListViewItem lvit = new ListViewItem();
lvit.Text = _PivotItem.Caption;
if (FindListItem(_PivotItem.Caption, lvActiveFilter, 2))
_PivotItem.Visible = true;
else
_PivotItem.Visible = false;
}

Now setting a specific Item's Visible property to True doesn't seem to be enough in order to make that item to show up in the resulting PT, specially not if the item has no data.:(
Now there IS a flag within Excel PivotField that you can set to true (= check the corresponding checkbox "Show items with empty data") and that would affect the PT with desired result but, how could I accomplish this behaviour using either C# -> Interop or VBA?

BR,
perco754
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top