首页 > 解决方案 > 角度 ag-grid 如何设置标题样式

问题描述

我在我的角度应用程序中使用 ag-grid 并尝试导出到 excel。我想在 excel 中设置标题行的样式。谁能帮助我如何实现这一目标?我尝试了以下但似乎没有工作。

   this.excelStyles = [
      {
        id: 'smallFont',
        font: {
          fontName:'Calibri',
          size: 9
        }
      },
      {
        id:'blueBackground',
        interior: {
          color: 'blue',
          pattern: 'solid'
        }
      }
    ]

defaultColDef: {
  cellClassRules: {
    smallFont: (params) => true,
    blueBackground: (params) => params.rowIndex == 0
  }
}

谢谢

标签: ag-grid-angular

解决方案


如下所示使用 id 'header' 设置 excelstyle 将为 excel 标题设置样式。

{
  id:'header',
  interior: {
    color: '#002776',
    pattern: 'solid'
  },
  font: {
    color: '#ffffff',
    fontName: 'Calibri',
    size: 9,
    bold: true
  }
}  

推荐阅读