How to add a row and column in between in MS Excel sheet

Hi Team,
I have a MS Excel sheet having 10 rows and 10 columns filled with values, i have to insert a row in between i.e., insert a row after sixth row, and insert a column i.e. insert a new column after fourth column.
Is there any library and function available which would help me to insert a row or a column at a particular position.
Thanks

Maybe, it’s the openpyxl library that you seek…

https://openpyxl.readthedocs.io

Thanks Rob, but there is not direct function to add a row/column in between.

No worries.

I thought that the methods .insert_rows() and .insert_cols() would do what you needed, but if not, the only other thing I can think of is to have a loop that shifts the data (a kind of cut and paste, if you will), but that could (potentially) get very complex, very quickly.

It does look like openpyxl will do exactly what you need, Tariq. From Deleting Rows and Columns:

The default is one row or column. For example to insert a row at 7 (before the existing row 7):
>>> exampleWorksheet.insert_rows(7)

I already suggested (in the post above) that this library could do what is required, but this option has been rejected by @TariqAbbasi

You certainly did and it looks like that was accurate advice. I posted to offer the specific reference so that Tariq could have a closer look at the exact section.

This is exactly what ~.insert_rows() and ~.insert_columns() do.

Thanks Rob, let me try this.

Thanks Lenand, let me use it and check whether it fullfil my requirements.