vb.net - Add Pivot Table to Existing Worksheet -
using vb.net can create excel pivot table in new worksheet, when try create same pivot table below data set within same worksheet fails create pivot table. code below shows working code , non-working code. missing.
' adding pivot table new worksheet works fine xlbook .worksheets.add(after:=.worksheets(.worksheets.count)) end xlbook.pivotcaches.create(sourcetype:=excel.xlpivottablesourcetype.xldatabase, sourcedata:="orders table!r1c1:r26c19", _ version:=excel.xlpivottableversionlist.xlpivottableversion12).createpivottable(tabledestination:="sheet3!r3c1", tablename:="pivottable1") xlsheet = xlbook.worksheets("sheet3") xlsheet.cells(3, 1).select() ' adding pivot table existing "orders table" worksheet fails xlbook.pivotcaches.create(sourcetype:=excel.xlpivottablesourcetype.xldatabase, sourcedata:="orders table!r1c1:r26c19", _ version:=excel.xlpivottableversionlist.xlpivottableversion12).createpivottable(tabledestination:="orders table!r30c1", tablename:="pivottable1") xlsheet = xlbook.worksheets("orders table") xlsheet.cells(30, 1).select()
i think reason problem you're trying add pivot sheet target.
Comments
Post a Comment