Reputation: 679
I've got a pivot table (see code below) where the source raw data is already sorted by client, year, and month. This means the row headings (A=Client, B=Year) are automatically sorted with the data, but the column headings (C2:N2=months of the year) become random ordered.
package.workbook.add_worksheet(name: "Samples Pivot") do |sheet|
data_range = "A1:E#{@raw_client_data_total_rows}"
sheet.add_pivot_table "A1:F1", data_range do |pivot_table|
pivot_table.data_sheet = package.workbook.worksheets.first
pivot_table.rows = %w[Client Year]
pivot_table.columns = %w[Month]
pivot_table.data = %w[Count]
end
end
If I open the spreadsheet in Excel, I can click on the auto-filter arrow on C1, which pops up an auto-filter dialog, and then I can manually sort the column headings by selecting "Ascending" and sort by "Month".
So is there a way to add this sort in caxlsx? I don't see any auto_filter
attribute in PivotTable
.
Upvotes: 0
Views: 152