When using the angularjs
number filter in angular-ui-grid
, I am facing an issue. The filter works perfectly fine within the grid, but when I export the grid to csv
and open it in Excel, the formatting is not maintained.
I have included the filter in the exporterFieldCallback
as well.
Within the grid:
cellFilter: 'number:6', type: 'number'
. And in the exporterFieldCallback
:
if(col.name == 'columnName'){
return $filter('number')(input,6);
}
The numbers are displayed with 6 decimal places in the grid. However, once exported to csv
and opened in Excel, the zeros are truncated.
You can view a demo of the angularjs number filter here, where the specified fractionSize displays correctly within the grid but not after export.
For example, if a value in the grid is 3.000000
, Excel only shows 3
.
If the value is 1.415400
in the grid, Excel truncates it to 1.4154
.
Why are the zeros getting truncated when exporting angular-ui-grid
to csv
and opening it in Excel? How can I ensure that values display consistently between the grid and Excel?