'How can I Pin an exported Excel file's header using JavaScript ag-grid?

I am adding some styling to my exported Excel file using ag-grid, I could change font colors, font size... etc I want the excel file's header to be pinned or fixed while scrolling.

I have checked this article: https://ag-grid.com/angular-data-grid/row-pinning/

but it did not help me much.

here is the styling code.

excelStyles: [
       {
          id: 'header',
          alignment: {
            vertical: 'Center',
            horizontal: 'Center',
          },
          interior: {
            color: '#4472C4',
            pattern: 'Solid',
            patternColor: undefined,
            height: 49,
          },
          font: {
            fontName: 'MS Pゴシック',
            // underline: 'Single',
            italic: false,
            color: '#ffffff',
            size: 14
          },
          borders: {
                borderBottom: {
                    color: "#000000", lineStyle: 'Continuous', weight: 3
                },
                borderTop: {
                    color: "#000000", lineStyle: 'Continuous', weight: 3
                }
            },
        },
],


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source