Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Export dynamic pivot table to Excel

Author  Topic 

barnabeck
Posting Yak Master

236 Posts

Posted - 2015-02-26 : 11:08:59
I know that this is an Excel question, but I guess it is much more likely that an SQL person using dynamic pivot tables had stepped on this, rather than any advanced Excel user.

I am exporting a dynamic pivot table to Excel through a Stored Procedure. If the Stored Procedure that executes the dynamic pivot table returns 7 columns in one run, and 4 columns in the following update, then I have 3 orphaned columns that are still displayed in the spreadsheet. There isn't any content related to them, but the empty columns with their headers are bothering enough.

I've been trying to play with the data connection properties, but nothing deletes unused columns from former data executions.

Anyone knows how to achieve this?
Martin

barnabeck
Posting Yak Master

236 Posts

Posted - 2015-03-02 : 05:18:22
I finally managed to get the Data updates correctly by configuring the External Data Properties in the following way

Data formatting and layout:
(checked) - Preserve column sort/filter/layout
(checked) - Preserve cell formatting

If the number of rows in the data range changes upon refresh
(checked) - Overwrite existing cells with new data, clear unused cells

the rest is unchecked and works correctly for changes in the amount of columns on refresh

Go to Top of Page
   

- Advertisement -