How to remove headers from excel download in Pivot Table

1 Answer 113 Views
Excel Export
Jaskaran
Top achievements
Rank 1
Jaskaran asked on 12 Jul 2023, 04:24 PM | edited on 13 Jul 2023, 02:10 PM

Hello Team,

I am using Kendo React Pivot Table version @progress/kendo-react-pivotgrid": "^5.9.0". For downlaoding pivot table as excel, l am using saveAsExcel function given by export-to-excel library and followed this https://www.telerik.com/kendo-react-ui/components/pivotgrid/excel/ documentation.  I want to remove row and column headers from downloaded excel file. I have added screenshot for same. Your little help will be appriciated.

Thank You in Advance

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 14 Jul 2023, 07:55 AM

Hi Jaskaran,

The logic that populates the excel file data is within the "export-to-excel.js" file and the code for the captions is the following:

const cells = (rows, type, callback) => {
  let result = [];
  rows.forEach((axisRow, i) => {
    let row = [];
    axisRow.cells.forEach(cell => {
      if (cell) {
        row.push({
          background: '#7a7a7a',
          color: '#fff',
          verticalAlign: 'top',
          value: cell.caption,
          colSpan: cell.colSpan || 1,
          rowSpan: cell.rowSpan || 1
        });
      }
    });

If you want to remove the captions you can pass an empty string to the value:

const cells = (rows, type, callback) => {
  let result = [];
  rows.forEach((axisRow, i) => {
    let row = [];
    axisRow.cells.forEach(cell => {
      if (cell) {
        row.push({
          background: '#7a7a7a',
          color: '#fff',
          verticalAlign: 'top',
          value: "",
          colSpan: cell.colSpan || 1,
          rowSpan: cell.rowSpan || 1
        });
      }
    });

If you want to remove only particular captions, you can add some method that will return empty string only if the "cell.caption" equals "col", "row", or "PDF" for example.

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Tags
Excel Export
Asked by
Jaskaran
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or