Thanks again for your suggestion. is_calced property in xl_cell would be great.
I have tested using xl.WorksheetFunction.CountA (see isCacled below) . Now I call this in another function decorated with @xl_func, (with explicit of range to check isCalced as string) see further below.
This works Okay as long as the function is registered with thread_safe = False. Once thread_safe=True, xl.WorksheetFunction.CountA will throw exception com_error: (-2146777998, 'OLE error 0x800ac472', None, None)
, the famous VBA_E_IGNORE exception
which is discussed at MSDN here : http://social.msdn.microsoft.com/Forums/vstudio/en-US/9168f9f2-e5bc-4535-8d7d-4e374ab8ff09/hresult-800ac472-from-set-operations-in-excel?forum=vsto
. It seems that in concurrent function calculation, Excel will be in suspension mode and fail to entertain any COM call.
Because my original goal is to use this in a thread_safe=True function, do you think that using xl_cell property as you mention would work in this case?
xl = _xl_app()
myRange = xl.Range(excelRangeStr)
logging.error("isCacled failed %s is not a valid range"%str(excelRangeStr) )
for theParameter in myRange:
vHasFormula = theParameter.HasFormula
if vHasFormula == True:
logging.info("isCalced:HasFormula for %s"%str(theParameter.Address))
if xl.WorksheetFunction.CountA(theParameter) == 0:
logging.info("isCalced:False for %s"%str(excelRangeStr))
logging.error("isCacled failed with %s"%str(excelRangeStr) )
@xl_func("string blah, cached_object co, string isCacledRange : cached_object ", thread_safe=True)
def doSomethingLong(blah, co, isCacledRange):
if isCacledRange != "" and cacheObject.isCacled(isCacledRange) == False: