Author Topic: Leading '0' values are not exported properly.  (Read 2758 times)

gtwangi

  • Newbie
  • *
  • Posts: 9
    • View Profile
Leading '0' values are not exported properly.
« on: March 28, 2019, 04:18:46 pm »
When exporting leading '0' values(ex. '012345') by using 'exportData' method, the leading zero are deleted in Excel(12345 instead of '012345').

in pqgrid    ->>  in excel
'012345' ->>  12345

Is there way to preserve the leading zero while exporting to excel?


« Last Edit: March 28, 2019, 06:12:28 pm by gtwangi »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6320
    • View Profile
Re: Leading '0' values are not exported properly.
« Reply #1 on: April 09, 2019, 01:32:22 pm »
It can be done by adding dataType: 'string' and format property to the column.

Code: [Select]
format: function(val){
return " "+val;
},

For example, it can be verified by replacing Freight column definition in this demo ( https://paramquery.com/pro/demos/export ) with this:

Code: [Select]
                       { title: "Freight", width: 120,
format: function(val){
return " "+val;
},
//dataType: "float",
dataIndx: "Freight"
},
« Last Edit: April 09, 2019, 01:34:32 pm by paramquery »

gtwangi

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Leading '0' values are not exported properly.
« Reply #2 on: April 16, 2019, 08:10:06 pm »
I appreciate your help.
The solution you provided doesn't work on v5.5.0 (I'm using). it probably works well above v5.6

1.
Is there a solution for v5.5.0?

2.
How compatible are v5.5.0 and v5.6.1? which part of code should I modify when upgrading my app to v5.6.1?




« Last Edit: April 16, 2019, 08:12:06 pm by gtwangi »

gtwangi

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Leading '0' values are not exported properly.
« Reply #3 on: April 22, 2019, 04:14:37 pm »
There is another issue about exporting data.
Negative number is exported as number on v5.5 properly. but after I upgraded pqgrid version to 5.6.1, negative number is exported as text.



How I could export this as number?