Author Topic: Export to Excel - Rendered cell values not being exported as displayed in grid  (Read 4255 times)

qfinsoft

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
I currently have export to excel functionality working for the most part, except for one or two issues.

First, in the case of exporting a grid to excel, where a column's cell is rendered to display text different than it's value (in this case, displays the territory name rather than territory id), it exports the id rather than the rendered text.  Is this by design?  Is there a way to export what has been rendered in the cells, rather than its stored 'value'?  Keep in mind I need to keep column filtering working

Here is the colModel for the column I am referring to:

Code: [Select]
{
                    title: "Territories",
                    width: 85,
                    dataType: "string",
                    dataIndx: "territories",
                    editable: false,
                    render: function(ui) {
                        if (ui.rowData.territories !== undefined) {
                            var terrDisplay = "";

                            for (var i = 0, len = ui.cellData.length; i < len; i++) {
                                terrDisplay += territoryLookup[ui.cellData[i]];
                                if (i+1 < len) { terrDisplay += ","; }
                            }

                            return terrDisplay;
                        }
                    },
                    filter: {
                        type: 'select',
                        listeners: ['change'],
                        labelIndx: 'name',
                        valueIndx: '_id',
                        options: localstorage.territories,
                        prepend: {"": ""}
                    }
},

On a somewhat related note, cells in other columns (not necessarily the territories column above) with empty values are currently being exported with value 'undefined'.  Is there a simple way around this little quirk as well?

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
1) rendered cells are not exported but only the data is exported.

2) There is property column.copy which when set to false could be used to prevent export of certain columns.

http://paramquery.com/pro/api#option-column-copy

Sunny

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
Hi,

Is there any way or workaround to export the rendered cells ? In that way it solves two issues,

1. It will prevent showing Id instead of Value(in drop-down columns) and
2. other it would prevent displaying 'undefined' where some cells are blank..

Appreciate in advance.

Regards.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Currently there isn't a way to export the rendered cells.

But it has been added as an option in the upcoming version .

Sunny

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 59
    • View Profile
Thank you very much.