Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken formatting in both exported CSV and Excel files since v4.6.1 #6887

Closed
dmitry-borzov opened this issue Nov 8, 2018 · 5 comments
Closed

Comments

@dmitry-borzov
Copy link
Contributor

dmitry-borzov commented Nov 8, 2018

Plunkr:
http://plnkr.co/edit/7yFTvr1z35AzmlZjzDUF?p=preview

Expected result (as it worked until v4.4.6):
8.99
-13.09
51.45
-1,128.65

Actual result in CSV:
null9
#NAME?
null51
-null1,129

Actual result in Excel:
null9
-null13
null51
-null1,129

It looks like the bug was introduced in the following commit:
3207b29

The code in the commit changes filter parameters from
return $filter('currency')(value, "");
to
return $filter('currency')(value, null, null);
It gives wrong output.

dmitry-borzov referenced this issue Nov 8, 2018
This should fix export csv with cellFilter.

closes #6784
@johnoscott
Copy link

anyone know if this is getting fixed ?

@johnoscott
Copy link

johnoscott commented Jul 9, 2019

workaround is to override the broken default implementation by setting this in your grid options

grid.options = {
    // return raw call value without cellFilters being applied			
    exporterFieldCallback: function ( grid, row, col, value ) {
        return value;
   },...
}

@Neonchen
Copy link

Neonchen commented May 13, 2020

Extending the workaround from @johnoscott you can just apply all cellFilters by yourself:

exporterFieldCallback: function ( grid, row, col, value ) {
        // example for a more advanced filter
        if(col.cellFilter === "date:\'dd.MM.yyyy\'") { 
            value = $filter('date')(value, 'dd.MM.yyyy')

        //every common filter like 'currency'
        } else if ( col.cellFilter !== "") {
           value = $filter(col.cellFilter)(value)
        }
        //all cols without filter just return the value
        return value;
}

@Cornchips007
Copy link

Cornchips007 commented Aug 26, 2020

How are people not getting their build broken by the parameters not being found? I can replace grid with this.myGrid but row, col and value I'm just not sure about.

I'm using typescript but can type them as any.

image

Answer: Just add types to the parameters. e.g. (grid: uiGrid.IGridApi, row: uiGrid.IGridRow, col: uiGrid.IGridColumn, input: any)

@mportuga
Copy link
Member

mportuga commented Aug 1, 2021

@mportuga mportuga closed this as completed Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants