我正在尝试遍历所有切片器,然后将其导出为 PDF。我在循环切片器项目时遇到问题。
我尝试了以下方法,
items = ['abs', 'abc', 'abd', 'cdc', 'dvd']
for each in range(0, len(items)):
itemSlicer = items[each]
print(itemSlicer )
workbook.SlicerCaches("Slicer_items").ClearManualFilter()
workbook.SlicerCaches("Slicer_items").SlicerItems().Selected = True
workbook.ActiveSheet.ExportAsFixedFormat(0, path + label)
我得到了错误workbook.SlicerCaches("Slicer_items").SlicerItems().Selected = True
错误,
com_error Traceback (most recent call last)
<ipython-input-33-a48809dba26f> in <module>
8
---> 10 workbook.SlicerCaches("Slicer_age").SlicerItems().Selected = True
11
~\AppData\Local\Temp\1\gen_py\3.8\00020813-0000-0000-C000-000000000046x0x1x9\SlicerItems.py in __call__(self, Index)
59 # Default method for this class is '_Default'
60 def __call__(self, Index=defaultNamedNotOptArg):
---> 61 ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((12, 1),),Index
62 )
63 if ret is not None:
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None)