excelExport - How to delete a cell

1 Answer 28 Views
Grid
Kent
Top achievements
Rank 1
Kent asked on 13 Feb 2025, 04:34 PM

In my excelExport JavaScript function for my Kendo Grid definition I am requesting the merge of two cells using:


                    sheet.mergedCells = [];
                    sheet.mergedCells.push("A2:A3");

On the created spreadsheet I do get a merged cell at A2 spanning two rows, but the cell that was at A3 (and all of the cells to the right of it) get shifted right instead of being absorbed by the merge.

So I now want to delete the cell at A3.  But I can't find any way to select/delete cells using this api.

Any thoughts on how to delete that cell?

1 Answer, 1 is accepted

Sort by
0
Accepted
Neli
Telerik team
answered on 18 Feb 2025, 01:01 PM

Hi Kent,

You could try to modify the cell array in the next row. For example, you could remove a cell in the row as demonstrated below:

excelExport: function(e) {
            let sheet = e.workbook.sheets[0];
            sheet.mergedCells = [];
            sheet.mergedCells.push("A2:A3");
            sheet.rows[2].cells.shift()
},

Here is a Dojo example where this is demonstrated - https://dojo.telerik.com/GbsPMjsl.

I hope this helps.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Kent
Top achievements
Rank 1
commented on 18 Feb 2025, 04:44 PM

Thanks for that suggestion.  At some point I realized I could just shift the cells over - but I did that manually via a loop.  The loop approach works great, but utilizing the cells.shift() method is obviously the better way to go.
Tags
Grid
Asked by
Kent
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or