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

Value formatting via aggregates do not export to excel correctly in 5.4.0 #971

Open
Austinb opened this issue Sep 2, 2020 · 7 comments
Open
Labels

Comments

@Austinb
Copy link

Austinb commented Sep 2, 2020

After some trial and error and looking at the exported XLSX code it appears the exported aggregate summary rows are not properly formatted when exported to excel via the exportToExcel command.

Easiest example would be using the built in currency formatters.

aggregates: [
            {
              formatter: 'integer',
              formatoptions: {
                thousandsSeparator: '',
              },
              label: 'Total',
              width: 120,
              align: 'right',
              aggregator: 'sum',
              summaryType: 'sum',
              member: 'total',
            },
            {
              formatter: 'currency',
              formatoptions: {
                decimalSeparator: '.',
                thousandsSeparator: ',',
                decimalPlaces: 5,
                prefix: '$',
                defaultValue: '0.00',
              },
              label: 'Revenue',
              width: 80,
              align: 'right',
              aggregator: 'sum',
              summaryType: 'sum',
              member: 'revenue',
            },
            ...
]

When exporting to excel using these aggregates the 'Revenue' column for the aggregate row is tagged as <c t="inlineStr" r="CX"> instead of the format <c r="EX" s="57"> which is for currency. All of the normal data rows before the aggregate sum rows show up properly. Issue also happens on columns using custom aggregator and summaryType functions to manipulate the cell's data.

Also using the default integer format with a defined thousandsSeparator or the default format causes the cell to be tagged as a string as well.

aggregates: [
            {
              formatter: 'integer',
              formatoptions: {
                thousandsSeparator: ',',
              },
              label: 'Total',
              width: 120,
              align: 'right',
              aggregator: 'sum',
              summaryType: 'sum',
              member: 'total',
            },
]

This same issue happens apparently only with small integers < 10. For the Total column any single digit numbers are also flagged as strings. I would assume that issue is related to the above.

Any help would be appreciated.

@tonytomov tonytomov added the Bug label Sep 2, 2020
@tonytomov
Copy link
Owner

tonytomov commented Sep 2, 2020

Thanks.

I will check with the demo provided from you

Kind Regards

@tonytomov
Copy link
Owner

The problem exists, but the fix is not trivial. In most cases the footer(header) column with a number can contain text like Total and etc. In this case applying the excel number formatter will cause bad output.

We need a good auto detect number parser for footer (header) row.

Will see what I can do.

@tonytomov
Copy link
Owner

I speak about summary footer(header) row

@tonytomov
Copy link
Owner

tonytomov commented Sep 22, 2020

Hello,

I have do some fix on this. Can you please check if it is ok for you?
Thanks

@Austinb
Copy link
Author

Austinb commented Oct 16, 2020

Sorry for the delayed test, been on other projects.

I got back to this and downloaded 5.5.0 via the download link on the main site. Exporting looks good for the most part except sometimes items are are percentages are not always marked as percentages in the exported sheet. It seems to be random from what I can tell. What is the excel_format supposed to be for a percentage field? I do not have one defined. The issue seems to affect any type of number, 0, 2-digit, etc... This is a custom formater to make the field into a %.

formatter: function (cellvalue, options, rowObject) {
    cellvalue = cellvalue || 0.00
    return `${parseFloat(cellvalue).toFixed(1)}%`
},

There is another issue with overriding the totals in 5.5.0 but that maybe a separate issue.

@Austinb
Copy link
Author

Austinb commented Oct 16, 2020

I just tried using the currency formater and defining it to look like a percentage. It seems to work better but the same issue with random values being strings still persists.

formatter: 'currency',
formatoptions: {
    decimalSeparator: '.',
    thousandsSeparator: ',',
    decimalPlaces: 2,
    prefix: '',
    suffix: '%',
    defaultValue: '0.00',
},

Thanks for your help on this!

@Austinb
Copy link
Author

Austinb commented Oct 16, 2020

I downloaded the version from github for 5.5.1 and it seems to be the same as above. It all works except the random percentage formatting issuer. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants