0

I would like to find the topleft cell and bottomright cell in an Excel worksheet range, which is a bounding box of all occupied cells in the sheet, from ironpython 2.7.5 on win 7.

My code:

 from Microsoft.Office.Interop import Excel
 from System import Type

 excel = Excel.ApplicationClass()
 workbook = excel.Workbooks.Open(excelFilename, False, True)
 allWorksheets = workbook.WorkSheets
 for aWorkSheet in allWorksheets:
      last = aWs.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);
      range = excel.get_Range("A1", last);
      print "a worksheet range is " + str(range)

I need to find the topleft cell and bottomright cell in the "range" The links at

Programmatically getting the last filled excel row using C#

How to get the range of occupied cells in excel sheet

Cannot help me.

Any suggestions ? Thanks

Community
  • 1
  • 1
Lily
  • 295
  • 1
  • 4
  • 14

1 Answers1

0

You can get the range with .Value like this:

 ws.Range("A3:B4").Value = "A3:B4"

As shown on line of 11 of the ranges_and_offsets.py example.

Tim Penner
  • 3,551
  • 21
  • 36