Please excuse what should be a simple question, but alas, I’m finding very little simple about writing python macros.
I have a spreadsheet with a column with a series of rows, most, but not all containing a datum, usually a 3 character code. My plan is to use this 3 character code to access (way down the road) a postgresql db and retrieve data and insert it into an adjacent (nearby) column. There will be occasional blank cells in this column which I need to do nothing with.
My frustration with trying to detect a simple empty cell has spawned a new question. uno claims to have an enumerated value for cell types (ref: Pytoniak)
com.sun.star.table.CellContentType.EMPTY
com.sun.star.table.CellContentType.VALUE
com.sun.star.table.CellContentType.STRING
etc.
Python tells me that it can’t find com.sun.star.table.CellContentType.EMPTY or any of the variants.
So, my question is twofold:
What is the correct way to detect a cell property?
Where (or what) are the enumberated values associated with that that I can put in in if/else statement?
import sys
import uno
import unohelper
import time
import urllib.request
from datetime import date
and
for rows in range(0, rowcount):
oCell1 = oSheet.getCellByPosition(0,rows)
oCell2 = oSheet.getCellByPosition(1,rows)
#oCell2.String = oCell1.String
if oCell1.Type == com.sun.star.table.CellContentType.EMPTY :
oCell2.String = 'EmptyNULL'
else:
oCell2.String = 'Full'
This fails with a com.sun.star.table.CellContentType.EMPTY not valid error.
The oo/loBASIC code examples use the above format. I can find none for python. Should I give up on python/lo? These seem to me to be very fundamental tasks that I can’t seem to figure out on my own with uno. Is there a good source for this kind of information that I am overlooking? Thanks folks.