datatable excel export, how can we apply multiple styles to same cell with IE

datatable excel export, how can we apply multiple styles to same cell with IE

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Can you give me a link to a page showing the issue please?

    Allan

  • jacek_kjacek_k Posts: 6Questions: 1Answers: 0

    I cant show it to you but i have popup from Excel like that: Excel completed file-level validation and repair. Some parts of this workbook may have been repaired or rejected.
    Records repaired: Information about cells from /xl/worksheets/sheet1.xml
    (free translation)

    and info from log file:

    <?xml version="1.0" encoding="UTF-8" standalone="true"?>

    -<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">

    <logFileName>error165920_01.xml</logFileName>

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    If you could use JSFiddle or http://live.datatables.net to recreate the problem I would be happy to take a look at it. I need a page showing the issue to be able to debug it. Note it would be worth using the nightly version of the HTML5 buttons if you aren't already.

    Allan

  • jacek_kjacek_k Posts: 6Questions: 1Answers: 0

    from my cshtml file:

    function loadData(data) {

    $('#Table').DataTable({
        data: data,
        dom: 'Bfrtip',
        animation: true,
        paging: true,
        searching: true,
        bInfo: true,
        autoWidth: false,
        buttons: [
            {
                extend: 'excelHtml5',
                title: null,
                messageTop: 'Report',
                createEmptyCells: true,             
                customize: function( xlsx ) {
    
    
                var sSh = xlsx.xl['styles.xml'];
                 var lastXfIndex = $('cellXfs xf', sSh).length - 1;
    
                 var f1 = '<fill><patternFill patternType="solid"><fgColor rgb="FFFF0000" /><bgColor indexed="64" /></patternFill></fill>';
                 var f2 = '<fill><patternFill patternType="solid"><fgColor rgb="FFFFA500" /><bgColor indexed="64" /></patternFill></fill>';
                 var f3 = '<fill><patternFill patternType="solid"><fgColor rgb="FF008000" /><bgColor indexed="64" /></patternFill></fill>';
                 var f4 = '<fill><patternFill patternType="solid"><fgColor rgb="FFD3D3D3" /><bgColor indexed="64" /></patternFill></fill>';
                 var f5 = '<fill><patternFill patternType="solid"><fgColor rgb="FF365F91" /><bgColor indexed="64" /></patternFill></fill>';
                 var s1 = '<xf numFmtId="0" fontId="1" fillId="0" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment vertical="top" horizontal="left" wrapText="1" /></xf>';
                 var s2 = '<xf numFmtId="0" fontId="0" fillId="6" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment vertical="top" horizontal="left" wrapText="1" /></xf>';
                 var s3 = '<xf numFmtId="0" fontId="1" fillId="10" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment horizontal="center" vertical="top" wrapText="1" /></xf>';
                 var s4 = '<xf numFmtId="0" fontId="0" fillId="7" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment vertical="top" horizontal="left" wrapText="1" /></xf>';
                 var s5 = '<xf numFmtId="0" fontId="0" fillId="8" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment vertical="top" horizontal="left" wrapText="1" /></xf>';
                 var s6 = '<xf numFmtId="0" fontId="0" fillId="9" borderId="1" applyFont="1" applyFill="1" applyBorder="1" xfId="0" applyAlignment="1"><alignment vertical="top" horizontal="left" wrapText="1" /></xf>';
                sSh.childNodes[0].childNodes[2].innerHTML += f1 + f2 + f3 + f4 + f5;
                sSh.childNodes[0].childNodes[5].innerHTML += s1 + s2 + s3 + s4 + s5 + s6;       
                var normal = lastXfIndex + 1;   
                var red = lastXfIndex + 2;      
                var head = lastXfIndex + 3;         
                var orange = lastXfIndex + 4;           
                var green = lastXfIndex + 5;            
                var lightGrey = lastXfIndex + 6;
                $('row c', sheet).attr('s', normal);
                $('row:nth-child(2) c', sheet).attr('s', head); 
                var sheet = xlsx.xl.worksheets['sheet1.xml'];           
    
    
    
                var col = $('col', sheet);
                $(col[0]).attr('width', 4);
                $(col[1]).attr('width', 15);
                $(col[2]).attr('width', 15);
                $(col[3]).attr('width', 15);
                $(col[4]).attr('width', 20);
                $(col[5]).attr('width', 20);
                $(col[6]).attr('width', 20);
                $(col[7]).attr('width', 15);
                $(col[8]).attr('width', 15);
                $(col[9]).attr('width', 15);
                $(col[10]).attr('width', 20);
                $(col[11]).attr('width', 15);
                $(col[12]).attr('width', 15);
                $(col[13]).attr('width', 20);   
    
    
    
                }
            }
        ],
        columns: [
    
            { "data": "s1" },
            { "data": "s2" },
            { "data": "s3" },
            { "data": "s4" },
            { "data": "s5" },
            { "data": "desc" },
            { "data": "add" },
            { "data": "owner" },
            { "data": "my_name" },
            { "data": "date" },
            { "data": "unit" },
            { "data": "accept_date" },
            { "data": "ver" },
            { "data": "comment" }
    
            ],
                        rowGroup: {
                        dataSrc: function(row) {
                          return moment(row.createdOn, moment.ISO_8601).format(DD/MM/YYYY);
                            }
                        },                  
                        createdRow: function( row, data, dataIndex){
    
                        },
    
                        columnDefs: [{
                            targets: '_all',
                            createdCell: function (td, cellData, rowData, row, col) {
    
    
                            }
                        }]          
    });
    

    }

This discussion has been closed.