pivot table - How can I shift the "subitems" in an Excel PivotTable to another column? -


i generate excel sheet contains data formatted so:

enter image description here

iow, "total packages", "total purchases", "average price", , "% of total" values located in column of own (data) each overarching (or sidearching) description.

when pivottablize data, places these values beneath each description:

enter image description here

this makes sense, accustomed previous appearance want replicated in pivottable. how can shift description "subitems" in pivottable own column?

this code use generate pivottable:

private void populatepivottablesheet() {     string northwest_corner_of_pivot_table = "a6";     addprepivottabledatatopivottablesheet();     var datarange = rawdataworksheet.cells[rawdataworksheet.dimension.address];     datarange.autofitcolumns();     var pivottable = pivottableworksheet.pivottables.add(                         pivottableworksheet.cells[northwest_corner_of_pivot_table],                          datarange,                          "pivottable");     pivottable.multiplefieldfilters = true;     pivottable.griddropzones = false;     pivottable.outline = false;     pivottable.outlinedata = false;     pivottable.showerror = true;     pivottable.errorcaption = "[error]";     pivottable.showheaders = true;     pivottable.useautoformatting = true;     pivottable.applywidthheightformats = true;     pivottable.showdrill = true;      // row field[s]     var descrowfield = pivottable.fields["description"];     pivottable.rowfields.add(descrowfield);      // column field[s]     var monthyrcolfield = pivottable.fields["monthyr"];     pivottable.columnfields.add(monthyrcolfield);      // data field[s]     var totqtyfield = pivottable.fields["totalqty"];     pivottable.datafields.add(totqtyfield);      var totpricefield = pivottable.fields["totalprice"];     pivottable.datafields.add(totpricefield);      // don't know how calc these vals here, have grab them source data sheet     var avgpricefield = pivottable.fields["avgprice"];     pivottable.datafields.add(avgpricefield);      var prcntgoftotalfield = pivottable.fields["prcntgoftotal"];     pivottable.datafields.add(prcntgoftotalfield); } 

so there 1 rowfield ("monthyr") values such "201509" , "201510", 1 columnfield ("description") , 4 datafields, align themseles under description column field. want shift 4 fields right, own column, , description label vertically centered between 4 values left. [how] possible?

try changing layout of table with

pivottable.rowaxislayout xltabularrow pivottable.mergelabels = true 

this result:

enter image description here

a little script in c# interop.excel. included using ;)

using microsoft.office.interop.excel; using system.runtime.interopservices; using excel = microsoft.office.interop.excel;  var excelapp = new excel.application(); excel.workbook wb = excelapp.workbooks.open(@"e:\42\testso.xlsx"); worksheet ws = wb.worksheets["sheetname"]; pivottable pt = ws.pivottables("dynamictablename"); pt.rowaxislayout(xllayoutrowtype.xltabularrow); pt.mergelabels = true; wb.save(); wb.close(); marshal.releasecomobject(ws); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -