Author Topic: Excel Export Formatting  (Read 5294 times)

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Excel Export Formatting
« on: May 04, 2018, 10:21:33 pm »
How do you format excel numbers?

I have tried data type float,  replacing commas dollar and dollar signs, etc. On every attempt, the exported file asks to convert text to numbers. I also tried adding colModel.format ='$###,###' and the data does not show with this option.

Using version 3.3.5.
« Last Edit: May 04, 2018, 10:41:51 pm by fmusignac »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Excel Export Formatting
« Reply #1 on: May 04, 2018, 10:57:38 pm »
In v3, formatted numbers with colModel.format ='$###,###.0' are always exported as strings.

In latest versions, formatted numbers ( e.g., in Freight column ) are exported as numbers when possible.

https://paramquery.com/pro/demos/export_local
« Last Edit: May 04, 2018, 11:01:12 pm by paramquery »

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #2 on: May 04, 2018, 11:12:32 pm »
So the only option is to upgrade? How's the compatibility, much effort to do so?

I know my company has upgraded to a later version but I am not seeing it on my download page. Can you help with that too?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Excel Export Formatting
« Reply #3 on: May 04, 2018, 11:32:12 pm »
The upgrade guide for v4 and v5 would assist you in upgrading from v3. The effort required depends upon amount of code written related to breaking changes.

Could you please share Transaction Id of latest renewal for your company so that your account can be upgraded accordingly.

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #4 on: May 04, 2018, 11:53:04 pm »
I don't have it with me but I was able to find v4 from our repository. The main breaking change I see is when we have an html table converted into a pq grid using $.paramquery.tableToArray, the html within some cells is being rendered as text and not the html controls (span, checkbox, etc.) that was there before. Is there a new option that I have to use to enable that rendering?

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #5 on: May 05, 2018, 12:25:11 am »
Looks like triggering the render with the same content works, but why would we have to do this when the same content is already there. This used to work on 3.3.5.
//...looping through colModel...
        colModel.render = function (ui) {
            var rowData = ui.rowData, dataIndx = ui.dataIndx;
            rowData.pq_cellcls = rowData.pq_cellcls || {};
            return rowData[dataIndx];
        }

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Excel Export Formatting
« Reply #6 on: May 07, 2018, 07:19:00 am »
The following is mentioned in the upgrade guide for v4.

Quote
Html entities in cell data with dataType: 'string' are escaped while rendering for security. If they are needed on purpose, then use dataType: 'html'. Any html entities added by render or postRender callbacks are not affected.

https://paramquery.com/pro/upgrade/Index40

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #7 on: May 11, 2018, 11:25:07 pm »
How about exporting numbers as strings? I'm having trouble with exporting numbers like 000111000, 111122222, 11100000, and have them show exactly like they need to be (acct numbers). Only way so far has been adding a "'" to the string but that's not acceptable. It used to work too.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Excel Export Formatting
« Reply #8 on: May 12, 2018, 02:09:05 pm »
Numbers with leading zeros like 000111000 can't be stored in number columns, otherwise leading zeros might get removed.

Please keep the column.dataType as "string" and then "000111000" is also exported as string.

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #9 on: May 14, 2018, 06:05:10 pm »
I tried the same initially but the data is changed when exported. It removes all leading zeroes and displays in scientific notation.

This is my sample data, logged in the javascript console for verification.

ALL
0004062104611461575
0004062107110507813
0004062109655336315
055007425063700110658115
100890100018982003312100
1044372000749303326
10443720008563710304
Account Group

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Excel Export Formatting
« Reply #10 on: May 15, 2018, 03:52:00 pm »
It works fine in v3 export demo

https://paramquery.com/pro/demos33/export_local

Step 1: Change the Freight column dataType as "string".

Step 2: Remove format from Freight column definition.

Step 3: Enter 000002341121 in one of the Freight cells.

Step 4: Export

It appears as 000002341121 in Excel file.

fmusignac

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Excel Export Formatting
« Reply #11 on: May 15, 2018, 06:51:45 pm »
I had to upgrade to v4, as suggested, to get the number formatting to work correctly.