I want to add colspan or rowspan on a table data
The situation is like I have a table of say 5×5, I want to merge columns by selecting say 2 columns by selecting them with mouse and want to merge. This is easy and I’m able to do till this but issue comes when

yellow shows colspan(merged)
and I try to do something like

Red shows what I want to merge so the final output should be all six cells merged into 1 and there are many other case of this type which can be seen.
So please guide me the way to proceed for the same.
You can do it like this, perhaps not the most elegant but it works, i hope it works for you:
first prepare the table with attributes.
then you can call this function sending it the selected tdies:
also add the next utility functions: