Method
#xlwings API
sht.api.Range(‘A1’).CurrentRegion.SpecialCells(xw.constants.CellType.xlCellTypeBlanks).Select()
sht.api.Range(‘B2’).CurrentRegion.SpecialCells(\
xw.constants.CellType.xlCellTypeBlanks).Select()
#sht.api.Range(‘B2’).CurrentRegion.SpecialCells(\
# xw.constants.CellType.xlCellTypeConstants).Select()
#sht.api.Range(‘B2’).CurrentRegion.SpecialCells(\
# xw.constants.CellType.xlCellTypeFormulas).Select()
#xlCellTypeComments #Cells with annotations
#xlCellTypeConstants #Cells with data
#xlCellTypeFormulas #Cells with formatting
RangeObject.SpecialCells(Type,Value)
|
Name |
Value |
Description |
|
xlCellTypeAllFormatConditions |
-4172 |
Cells with any format conditions |
|
xlCellTypeAllValidation |
-4174 |
Cells with validation conditions |
|
xlCellTypeBlanks |
4 |
Empty cells |
|
xlCellTypeComments |
-4144 |
Cells with comments |
|
xlCellTypeConstants |
2 |
Cells containing constants |
|
xlCellTypeFormulas |
-4123 |
Cells containing formulas |
|
xlCellTypeLastCell |
11 |
The last cell in the used range |
|
xlCellTypeSameFormatConditions |
-4173 |
Cells with the same format conditions |
|
xlCellTypeSameValidation |
-4175 |
Cells with the same validation |
|
xlCellTypeVisible |
12 |
All visible cells |
Sample Code
#Reference special cells
import xlwings as xw #Import the xlwings package
app=xw.App()
bk=app.books.open('special.xlsx') #Get the active workbook
sht=bk.sheets.active #Get the active worksheet
#xlwings API
sht.api.Range('B2').CurrentRegion.SpecialCells(\
xw.constants.CellType.xlCellTypeBlanks).Select()
#sht.api.Range('B2').CurrentRegion.SpecialCells(\
# xw.constants.CellType.xlCellTypeConstants).Select()
#sht.api.Range('B2').CurrentRegion.SpecialCells(\
# xw.constants.CellType.xlCellTypeFormulas).Select()
#xlCellTypeComments #Cells with annotations
#xlCellTypeConstants #Cells with data
#xlCellTypeFormulas #Cells with formatting
#bk.close()
#app.kill()



Leave a Reply