Skip to content Skip to sidebar Skip to footer

Openpyxl + How Can I Search For Content In A Cell In Excel, And If The Content Matches The Search Criteria Update The Content?

I'm working on a Python (using 2.7) project to search through excel files for a UNC path for a server that is changing, and then update the cell with the new UNC path. I'm new to p

Solution 1:

The .value property of the Cell object is settable. This means that you can do any time something like:

cell.value = 'Helloooo ladies'

If this does not work it is probably because of the optimizer read mode. Check the optimized write mode if you needed... I always found the docs of openpyxl very complete and easy to follow.

How to look for information in the cell, or recognize what you are looking for is a very open question that can be solved in thousand different ways:

  • Checking the full content of the cell
  • Checking that a given substring is contained in the cell
  • Matching with a regular expression
  • ...

But this does not have anything to do with the openpyxl framework.

Post a Comment for "Openpyxl + How Can I Search For Content In A Cell In Excel, And If The Content Matches The Search Criteria Update The Content?"