javascript - I need to merge cells in a table. Exceljs library - Stack Overflow

There was a problem.I create worksheet in library EXCELJSfunction save_export(){var workbook = new Exc

There was a problem. I create worksheet in library EXCELJS

function save_export(){


    var workbook = new ExcelJS.Workbook();
    var worksheet = workbook.addWorksheet('sheet', {
      pageSetup:{paperSize: 9, orientation:'portrait',fitToPage: true,fitToHeight :  99 , fitToWidth :  1, horizontalCentered: true}
    }); 

    var tfoot = [];

        $(element).each(function(index_tfoot, element_tfoot) {
          $($(element_tfoot).find("#tfoot tr")).each(function(index_tr, element_tr) {

                $(this.cells).each(function(index_td, element_td) {
                    tfoot.push($(element_td).text());   
                });

                var row_foot = worksheet.addRow(tfoot);
                row_foot.eachCell(function(cell,rowNumber) {

                    cell.font = { name: 'Verdana', size: 11};
                    cell.alignment = {horizontal: 'center' };
                    cell.border = {
                      top: { style: "thin" },
                      left: { style: "thin" },
                      bottom: { style: "thin" },
                      right: { style: "thin" }
                    };


                    <!-- if(cell._value.model.value === 'ИТОГО'){ -->
                        <!-- var c = 'A'; -->
                        <!-- var r = cell._row._number; -->
                        <!-- var sum = c+r; -->
                        <!-- worksheet.mergeCells(sum + ': B31'); -->
                    <!-- } // ПОЛУЧИЛ ИТОГО -->

                });

                tfoot = [];

                });
        });

    });




        workbook.xlsx.writeBuffer().then(function (data) {
            var blob = new Blob([data], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            });

            saveAs(blob, "Исходная выборка.xlsx");
        });

};

when I merge cells, my merged rows over cells as in the screenshot "before". You see what number 238 disappear.

I need the cells to move.

[1]: .png - before [2]: .png - after

How we see in screenshots, cells merge and value ​​disappear ((

need to shift(

There was a problem. I create worksheet in library EXCELJS

function save_export(){


    var workbook = new ExcelJS.Workbook();
    var worksheet = workbook.addWorksheet('sheet', {
      pageSetup:{paperSize: 9, orientation:'portrait',fitToPage: true,fitToHeight :  99 , fitToWidth :  1, horizontalCentered: true}
    }); 

    var tfoot = [];

        $(element).each(function(index_tfoot, element_tfoot) {
          $($(element_tfoot).find("#tfoot tr")).each(function(index_tr, element_tr) {

                $(this.cells).each(function(index_td, element_td) {
                    tfoot.push($(element_td).text());   
                });

                var row_foot = worksheet.addRow(tfoot);
                row_foot.eachCell(function(cell,rowNumber) {

                    cell.font = { name: 'Verdana', size: 11};
                    cell.alignment = {horizontal: 'center' };
                    cell.border = {
                      top: { style: "thin" },
                      left: { style: "thin" },
                      bottom: { style: "thin" },
                      right: { style: "thin" }
                    };


                    <!-- if(cell._value.model.value === 'ИТОГО'){ -->
                        <!-- var c = 'A'; -->
                        <!-- var r = cell._row._number; -->
                        <!-- var sum = c+r; -->
                        <!-- worksheet.mergeCells(sum + ': B31'); -->
                    <!-- } // ПОЛУЧИЛ ИТОГО -->

                });

                tfoot = [];

                });
        });

    });




        workbook.xlsx.writeBuffer().then(function (data) {
            var blob = new Blob([data], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            });

            saveAs(blob, "Исходная выборка.xlsx");
        });

};

when I merge cells, my merged rows over cells as in the screenshot "before". You see what number 238 disappear.

I need the cells to move.

[1]: https://i.sstatic/kyquZ.png - before [2]: https://i.sstatic/0DeRc.png - after

How we see in screenshots, cells merge and value ​​disappear ((

need to shift(

Share Improve this question edited May 10, 2020 at 14:37 Паша Харченко asked May 10, 2020 at 14:26 Паша ХарченкоПаша Харченко 1011 gold badge2 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

I have faced the same problem.The data needs to be added after merging the cells. Please refer the documentation https://github./exceljs/exceljs#merged-cells

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745435147a4627574.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信