Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
IgxExcelExporterOptions cutting off everything after the first comma
posted

I am configuring my pivot grid like so:

 
  private configurePivotGrid() {
    const formatter = (value) => {
      // Check if the value is a valid number
      if (isNaN(value) || value === null || value === undefined) {
        return '';
      }
      
      // Format the value to two decimal places
      return new Intl.NumberFormat('en-US', {
        minimumFractionDigits: 2,
        maximumFractionDigits: 2,
      }).format(value);
    };

    const areaTypeDimensions = this.areaTypeList.map(areaType => ({
      memberName: areaType.name,
      displayName: areaType.name,
      memberFunction: (record) => {
        const areaTypeValue = record.areaTypeValues.find(value => value.areaType === areaType.name);
        return areaTypeValue ? `${areaTypeValue.areaValue}` : '';
      },
      enabled: false
    }));

    this.pivotConfig = {
      pivotKeys: {
        aggregations: 'aggregations',
        records: 'records',
        children: 'children',
        level: 'level',
        columnDimensionSeparator: '*',
        rowDimensionSeparator: '*',
      },
      columns: [

      ],
      rows: [
        { memberName: 'discipline', displayName: 'Discipline', enabled: false},
        { memberName: 'schedule', displayName: 'Schedule', enabled: false}
      ],
      values: [
        {
          member: 'quantity',
          displayName: 'Quantity',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'labourCost',
          displayName: 'Labour Cost',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'materialCost',
          displayName: 'Material Cost',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'totalCost',
          displayName: 'Total Cost',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'manhours',
          displayName: 'Manhours',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'factoredManhours',
          displayName: 'Factored Manhours',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        },
        {
          member: 'ccr',
          displayName: 'CCR',
          aggregate: {
            aggregator: IgxPivotNumericAggregate.sum,
            key: 'SUM',
            label: 'SUM'
          },
          enabled: true,
          formatter: (value) => formatter(value)
        }
      ],

      filters: [
        {
          memberName: 'drawingNumber',
          displayName: 'Drawing Number',
          enabled: false,
        },
        ...areaTypeDimensions,
        { memberName: 'drawingSheet', displayName: 'Drawing Sheet', enabled: false},
        { memberName: 'drawingRevision', displayName: 'Drawing Revision', enabled: false},
        { memberName: 'r6Item', displayName: 'R6 Item', enabled: false},
        { memberName: 'r7Item', displayName: 'R7 Item', enabled: false},
        { memberName: 'material', displayName: 'Material', enabled: false},
        { memberName: 'unitSymbol', displayName: 'Unit Symbol', enabled: false}
      ]
    };
  }

  public exportButtonHandler() {
    this.excelExportService.export(this.boqPivotGrid, new IgxExcelExporterOptions('BOQ Pivot Data'));
  }

<button *ngIf="boqGridRows && boqGridRows.length > 0 && hasDownloadPermissions" igxButton="contained" (click)="exportButtonHandler()" class="export-button">Export To Excel</button>

<div class="pivot-container" [hidden]="!(boqGridRows && boqGridRows.length > 0)">
    <igx-pivot-grid #boqPivotGrid [data]="boqGridRows" [pivotConfiguration]="pivotConfig" height="100%"  width="100%" [superCompactMode]="true" [defaultExpandState]='true' >

    </igx-pivot-grid>

    <igx-pivot-data-selector [grid]="boqPivotGrid"></igx-pivot-data-selector>
</div>



the reason for formatting the values like so:

          formatter: (value) => formatter(value)


was so that the tooltip would should the values to 2 decimal places but we still have our comma separated values. The issue I'm having now is that when I export to excel using the method exportButtonHandler the values are getting cut off after the first comma, So for example the value 16,275.38 would just get exported as 16. I'm not sure why this could be happening and how I could fix it? Or is there a better way of sorting the tooltip issue? Before the formatter it would show values as 16,275.3800000000023