如何更改Excel数据透视表的源数据 [英] How to change the source data of an Excel pivot table
本文介绍了如何更改Excel数据透视表的源数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
旨在实现: 我想改变源数据的使用VB.Net到一个名为范围在Excel中我的数据透视表。
我有:
<$p$p><$c$c>table.ChangePivotCache(wb.PivotCaches.Create(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:= sheet.Names(name_of_NamedRange)RefersToRange))。
例外:
参数不正确。 (异常来自HRESULT:80070057(E_INVALIDARG))
解决方案
SourceData必须是包含地址,包括工作表的名称,如我的表A1字符串:B10。试试这个:
<$p$p><$c$c>table.ChangePivotCache(wb.PivotCaches.Create(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:= sheet.Names(name_of_NamedRange)RefersToRange.Address。(外部:= TRUE)))Aim to achieve : I want to change the source data for my pivot table in Excel using VB.Net to a named range.
I have :
table.ChangePivotCache(wb.PivotCaches.Create(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:=sheet.Names("name_of_NamedRange").RefersToRange))
Exception :
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
解决方案
SourceData needs to be a string that contains the address, including the sheet name, like 'My Sheet'!A1:B10. Try this:
table.ChangePivotCache(wb.PivotCaches.Create(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:=sheet.Names("name_of_NamedRange").RefersToRange.Address(External:=True)))
这篇关于如何更改Excel数据透视表的源数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文