Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infragistics Issue with Exporting grid to Excel #2222

Open
AnmarAmmir opened this issue Feb 6, 2023 · 0 comments
Open

infragistics Issue with Exporting grid to Excel #2222

AnmarAmmir opened this issue Feb 6, 2023 · 0 comments
Labels

Comments

@AnmarAmmir
Copy link

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

  • ignite-ui version: 2022
  • browser: chrome

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)

@AnmarAmmir AnmarAmmir added the bug label Feb 6, 2023
@AnmarAmmir AnmarAmmir changed the title Issue with Exporting grid to Excel Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 participant