hello, can anyone help to solve this problem

hello, can anyone help to solve this problem

eryandieryandi Posts: 2Questions: 0Answers: 0
edited August 2023 in Free community support

hello, can anyone help to solve this problem, I'm displaying data in export excel, but the data doesn't want to appear.

can excel not read javascript?

"footerCallback": function ( row, data, start, end, display ) {
            var api = this.api(), data;
            api.column(14).visible( false );
            
            var intVal = function ( i ) {
                return typeof i === 'string' ?
                    i.replace(/[\$,%]/g, '')*1 :
                    typeof i === 'number' ?
                        i : 0;
            };
            
            var arrOut = [];
            var newdata = api.data().filter(function(text, value){ if(text[0] === '(TOTAL)' || text[0] === 'CELL 14') { arrOut.push(value); } });
            for (var i = 0; i < api.columns().data().count(); i++) {
                if(i === 1 || i === 3 || i === 18 || i === 19)
                {
                    continue;
                }
                
                var columnDataTotal = api
                    .column(i)
                    .data().filter(function(text, value){ return (arrOut.includes(value)) ? false : true; } );
                console.log(theColumnTotal);
                var theColumnTotal = columnDataTotal
                    .reduce(function(a, b) {
                        return intVal(a) + intVal(b);
                    }, 0);
            
                $(api.column(0).footer()).html("(AVG)");
                $(api.column(i).footer()).html(parseFloat(theColumnTotal / columnDataTotal.filter(function(text, value){ return text === '' ? false : true; }).count()).toFixed(0));
            },
        },

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • eryandieryandi Posts: 2Questions: 0Answers: 0

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    can excel not read javascript?

    I'm not sure what you mean. The answer is no, you can't just put Javascript in an Excel cell (although I believe there is an option for running Javascript in Excel these days, but that's one for Microsoft to support, not us :)).

    It looks like you might be referring to the footer cell content, not actually running JS in Excel? If that's the case, as Colin says, please link to a test case. The Excel export does support reading data from the table's footer cells.

    Allan

Sign In or Register to comment.