The XtraPivotGrid control is exported in a WYSIWYG (What You See Is What You Get) manner. According to this concept, items are exported as is, and this may cause an undesirable result. E.g. If column header width doesn't exactly match the field value width, the additional column will be produced. I'm afraid there is no way to avoid this problem in all cases. Let suppose that there are three Data Fields and only two Row Field. In this case, there is no any way to avoid cell merging without corrupting the layout.
Actually, we recommend turning off header export to avoid this problem. This can be done via the PivotGridOptionsPrint.PrintColumnHeaders, PivotGridOptionsPrint.PrintDataHeaders and PivotGridOptionsPrint.PrintFilterHeaders properties. However, in some cases, field headers may be necessary to describe the current pivot grid layout.
This example demonstrates how to create an ancillary Column Field that will have only one Field Value, which can be used to export a layout description. The PivotGridControl.CustomExportFieldValue event is used to provide a description to this field. Please note that you can generate any necessary string description by customizing the GetLayoutDiscription function.
Update: starting with version 15.1, the new Data-aware Export mode is available: WinForms & ASP.NET Pivot Grid Controls - New Excel Data Export Engine
Question Comments
Added By: Mila Remigio at: 11/6/2018 12:49:43 PM HI:
Can you please attach sample code for the ancillary column field with one Field Value for a WSYWIG export ?
Thanks