Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17100

Python–Inserting a Row in Excel

$
0
0

I've been searching for a solution for the last few days, and I never thought something so simple would be so near-impossible to find.

The projects I'm working on are stored in Excel files (from before I ever started programming), and I've been researching all the Python libraries I can find that support Excel.

All I want to do is insert an entire row, with or without its own content, just as one normally would be right-clicking in Excel and selecting 'insert'. Of course pandas has that function, but it works only on columns...no clue why they decided to create it that way.

When I use the "insert_rows" function in Openpxl, it completely destroys the documents. That's partly because I have a lot of merged and color-coded cells, I believe. So I'm just looking for alternative libraries to see if they have the same effect or not.

Does anyone know any library/function besides Openpxl that allows the simple task of inserting rows in Excel? Thanks in advance.

Then I was prompted to answer what I tried, what I expected, and what happened. So here's my answer:

I never really got the opportunity to try, because I never found complete steps that worked (other than Openpxl). When I saw suggestions on how to add rows, I originally thought it meant insert them. However, most sources just show how to add them at the end...not a big help.

Also, I came across Aspose [https://docs.aspose.com/cells/net/working-with-rows-and-columns/]. Their entire page reminded me of one of those schemes that promises to make you rich fast and then ends up conning you. Nearly all the instructions they gave, even on opening files, led to errors and conflicts. You can try for yourself.

Also, I'll attach an image of what my spreadsheet looked like before (insert_rows w/ Openpxl) and after: you can see that inserting a row wiped out the color, unmerged all the cells, and deleted the content from many of them too.

A clip of my originally created Excel DocWhat happened to it after performing insert_rows with Openpxl


Viewing all articles
Browse latest Browse all 17100

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>