This project has moved. For the latest updates, please go here.

Pivot Table Help: First RowField gets replaced by the second

Jan 4, 2013 at 6:45 PM
Edited Jan 4, 2013 at 6:46 PM


I have a couple of problems but first things first. I'm trying to create a pivot table that groups on the type column and the Degree column. I haven't added the grouping yet because I couldn't find a method to group on a string. However the first problem that I am having is that when I try to add a second row field, it always replaces the first one. Has anyone encountered this?
Sorry in advance if this has been asked before but I can't seem to find the answer.
        private static bool CreateCrosstab()
            using (ExcelPackage pck = new ExcelPackage(newFile))
                // get the handle to the existing worksheet
                //ExcelWorksheet wsData = pck.Workbook.Worksheets.Add("Summary");

                var wsPivot2 = pck.Workbook.Worksheets.Add("Summary");
                var pivotTable2 = wsPivot2.PivotTables.Add(wsPivot2.Cells["A1"], dataRange, "PerAttendee");

                //Also need rowfield for ProgramType

                pivotTable2.DataOnRows = false;                
            return true;
Jan 4, 2013 at 7:07 PM
Edited Jan 4, 2013 at 7:08 PM

It actually did work. The problem was that some of the types were null so I needed to scroll down quite a bit to see the first one.