Current Region as a Method either in openpyxl.worksheet.cell.Cell or .cell_range.CellRange

Issue #1313 new
anand Mohan created an issue

Excel has a CurrentRegion Method that is invoked as
Range(range_string).CurrentRegion

The idea behind this is to choose a region that have contiguous blank cells on all 4 sides ( except the case of cells in 1st column and cells in 1st row, in which case it will be 3 sides ) that separates from other regions

I have written a Python code that accomplishes this task. I have extended the CellRange class and added the method and it is working as expected.

Please let me know if this will be a useful feature and I will the submit code for review and standardization.
It may not be the best code, but has performed well and correctly in all my testing so far

Please see example snap shots attached for how CurrentRegion is expected to work
(reference link https://www.excel-easy.com/vba/examples/currentregion.html

Here is additional reference to the Method as implemented in Excel VBA
https://docs.microsoft.com/en-us/office/vba/api/excel.range.currentregio

Comments (3)

  1. CharlieC

    The CellRange class is itself a virtual object that does not interact directly with a worksheet so extending it to do this would be a substantial change. This sounds more like a worksheet method, which might internally use a CellRange object but not to check the values of cells.

  2. anand Mohan reporter

    Yes making it as part of the Worksheet class makes more sense.

    I will create a pull request and post the code.

    Thank You

  3. Log in to comment