Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Export shows text as numbers

Answered
Benjamin asked on June 25, 2020

Hello,
 
I have issue when exporting to Excel (from Flat), that it shows Text fields as Numbers (it is number, but of type String and it is parsed in Flexmonster component as text correctly).
 
Those are some ID numbers, and are shown in component as text. Issue with this conversion in Excel is that some of them may be i.e. 000673, and then in Excel it shows 673. Any suggestions?
 
Kind regards,
Benjamin

4 answers

Public
Milena Pechura Milena Pechura Flexmonster June 25, 2020

Hello, Benjamin, 
  
Thank you for reaching out to us. 
 
The described issue could be solved using MappingThis object allows setting field data types. 
We recommend specifying the data type for ID as “string”.
 
Please see the example for illustration: https://jsfiddle.net/flexmonster/vj1n8psq/
The following code snippet from the example demonstrates how ID field type could be specified: 

 
report: { 
    "dataSource": { 
    … 
    "mapping": { 
            "Id": { 
                "type": "string" 
            }, 
            … 

 

Please let us know if you have any additional questions.  
 
Best regards, 
Milena

Public
Milena Pechura Milena Pechura Flexmonster July 9, 2020

Hello, Benjamin, 

Our team is interested in whether you managed to fix the issue with exporting to Excel. 
Please let us know if the solution works for you.

Do not hesitate to contact us in case additional questions appear. 

Kind regards, 
Milena 

Public
Benjamin July 9, 2020

Hello Milena,
I want to say that I am happy with your support, and to apologize for not responding before; I somehow managed to preoccupy with some other things and put this aside.
The situation is somewhat specific: I was building some kind of dynamic display for reports, so at the moment of setting report, I don’t know about the fields nor their types (thus cannot set Mapping object myself), but I let Flexmonster handle it itself by putting appropriate type in CSV header (i.e. +customerID so my customerID field is String). In the grid that works perfectly fine, I just had issues when exported that in excel.

report: {
"dataSource": {
"type": "csv",
"filename": "url-to-csv"
},
"slice": {
"rows": [
{
"uniqueName": "customer ID"
},
...

This is what my report format looks like much-less. Basically, I am not writing Mapping object, and if I would, I don’t know types of all of the fields, since I use this component for different reports.
 
On the other hand, now when I came back to this problem, I tried exporting again, and now the issue isn’t there, and it shows it as String in excel, even without me changing anything on the setup.

Public
Milena Pechura Milena Pechura Flexmonster July 10, 2020

Hello, Benjamin,
 
We are pleased to hear that you are satisfied with our support, and your issue has been solved.
 
Please kindly note that it’s recommended to use mapping instead of CSV prefixes. Taking into account your case, we suggest setting the URL to the mapping instead of specifying the Mapping Object in the report. We have prepared an example for illustration: https://jsfiddle.net/flexmonster/5oxfubmc/.
 
Please also kindly note that for CSV data source you can set only the necessary types inside the mapping. All others will be defined automatically.
 
Do not hesitate to contact us in case any questions arise.
 
Best regards,
Milena

Please login or Register to Submit Answer