IgniteUI / ignite-ui

Ignite UI for jQuery by Infragistics
https://bit.ly/2kuu1fT
Other
477 stars 84 forks source link

infragistics Issue with Exporting grid to Excel #2222

Open AnmarAmmir opened 1 year ago

AnmarAmmir commented 1 year ago

Description

Can you please help with below issue.

I’m using Infragistics on out site, and currently my issue with filter by dates and exporting the data to excel, I’m using remote filter, please see also my findings below.

The error that I’m getting below (see attachment #1) 1

I was able to add alert in “infragistics.excel-bundled” to view the dates value for “a” and then I found that the date from the filter textbox is converted to milliseconds and causing the issue (see attachment #2)

2

3

Note: I'm using Filtering().Type(OpType.Local) in other page and the export working fine but we also we need to use the remote

and below is the excel export code

$('#exportButton').on('click', function () { var exportingIndicator = $('

'); var gridExcelExporter = new $.ig.GridExcelExporter(); var $grid = $('#grid'); gridExcelExporter.exportGrid(($grid), { gridStyling: "applied", fileName: "EIA", skipFilteringOn: ["record_status"], gridFeatureOptions: { filtering: "applied" },

            },
                {
                    exportStarting: function (e, args) {
                        showExportingIndicator(args.grid, exportingIndicator);
                    },
                    headerCellExported: function (e, args) {
                        if (args.headerText.contains("<br/>")) {
                            var regex = /<br\s*[\/]?>/gi;
                            var NewLineHeader = args.headerText.replace(regex, "\n")
                            args.xlRow.setCellValue(args.columnIndex, NewLineHeader);
                        }
                    },
                    cellExported: function (e, args) {
                        if (args.xlRow.index() == 0) {
                            return;
                        }
                        if (args.cellValue instanceof Date) {
                            var date = args.cellValue;
                            date.setDate(date.getUTCDate());
                            //date.setHours(date.getUTCHHours());
                            args.xlRow.cells(args.columnIndex).value(date);
                        }

                        //if (args.cellValue instanceof Date) {
                        //    var xlRow = args.xlRow;

                        //    var dateValue = args.cellValue.toString();
                        //    if (dateValue == "Invalid Date") {
                        //        args.xlRow.setCellValue(args.columnIndex, null);
                        //    }
                        //}
                    },
                    success: function () {
                        hideExportingIndicator(exportingIndicator);
                    },
                },
            );
        });
    });

also I have the converted utc date method

function formatDate(data, grid) { if (data != null) {

            if (data instanceof Date) {

                var utc = new Date(data).toUTCString();
                var index = utc.indexOf(",");
                var DateOnly = utc.substring(5, index + 13);
                var cc = DateOnly.replace(/ /g, "/")
                var fullYear = new Date(cc).toLocaleDateString("en-US");
                return fullYear;
            }
            else {
                if (data.contains("Date")) {
                    const myArray = data.split(/[()]+/).filter(function (e) { return e; });
                    var d = parseInt(myArray[1]);
                    var utc = new Date(d);
                    var fullYear = new Date(utc).toLocaleDateString("en-US");
                    return fullYear;
                }
            }
        }
        else {
            return "";
        }
    }

infragistics.core(text file).txt (https://github.com/IgniteUI/ignite-ui/files/10669545/infragistics.excel-bundled.text.file.txt)