PyXLL The Python Excel Add-In
  • Product
    • Features
    • Get Started
    • Request Demo
    • Download
  • Pricing
  • Resources
    • Documentation
    • Blog
    • Videos
    • FAQ
    • Learn Python
    • Customer Portal
    • About Us
  • Support
    • Documentation
    • Videos
    • FAQ
    • Contact Us
  • Contact Us
Table of Contents
  • PyXLL Documentation
  • Introduction to PyXLL
  • User Guide
  • Video Guides and Tutorials
  • API Reference
    • Worksheet Functions
    • Real Time Data
      • RTD
      • IterRTD
      • AsyncIterRTD
    • Macro Functions
    • Type Conversion
    • Ribbon Functions
    • Menu Functions
    • Plotting
    • Custom Task Panes
    • ActiveX Controls
    • Cell Formatting
    • Tables
    • Errors and Exceptions
    • Utility Functions
    • Event Handlers
    • Excel C API Functions
  • What’s new in PyXLL 5
  • Changelog
Close

Real Time Data¶

Please see Real Time Data in the User Guide for more details about writing RTD functions.

See also Worksheet Functions.

  • RTD

  • IterRTD

  • AsyncIterRTD

RTD¶

class RTD

RTD is a base class that should be derived from for use by functions wishing to return real time ticking data instead of a static value.

See Real Time Data for more information.

value

Current value. Setting the value notifies Excel that the value has been updated and the new value will be shown when Excel refreshes.

connect(self)

Called when Excel connects to this RTD instance, which occurs shortly after an Excel function has returned an RTD object.

May be overridden in the sub-class.

@Since PyXLL 4.2.0: May be an async method.

disconnect(self)

Called when Excel no longer needs the RTD instance. This is usually because there are no longer any cells that need it or because Excel is shutting down.

May be overridden in the sub-class.

@Since PyXLL 4.2.0: May be an async method.

detach(self)

Detatches the RTD instance from any Excel RTD functions.

After detaching, any subsequent calls to the Excel RTD function that created this object will result in the Python function be re-run.

See Restarting RTD Functions for more details.

@Since PyXLL 5.9.0

set_error(self, exc_type, exc_value, exc_traceback)

Update Excel with an error. E.g.:

def update(self):
    try:
        self.value = get_new_value()
    except:
        self.set_error(*sys.exc_info())

IterRTD¶

class IterRTD(RTD)

IterRTD implements the RTD base class and wraps a Python iterator.

This class creates a background thread and iterates over the iterator in that thread. Each value yielded by the iterator is sent to Excel.

In Python 3.7 and above, the background thread is run in the same context as the calling thread (see contextvars in the Python documentation for details about contexts and context variables).

When writing an RTD generator (RTD Generators) this class is what is used to wrap the generator object into an RTD object.

__init__(iterator, auto_detach=None)
Parameters:
  • iterator – A Python iterable object that will be iterated over.

  • auto_detach – If True, calls RTD.detach when then iterator is complete.

AsyncIterRTD¶

class AsyncIterRTD(RTD)

AsyncIterRTD implements the RTD base class and wraps a Python async iterator.

This class iterates over the async iterator in PyXLL’s asyncio event loop. Each value yielded by the iterator is sent to Excel.

In Python 3.7 and above, the background thread is run in the same context as the calling thread (see contextvars in the Python documentation for details about contexts and context variables).

When writing an RTD async generator (Async RTD Generators) this class is what is used to wrap the async generator object into an RTD object.

__init__(iterator, auto_detach=None)
Parameters:
  • iterator – A Python async iterable object that will be iterated over.

  • auto_detach – If True, calls RTD.detach when then iterator is complete.

« Worksheet Functions
Macro Functions »
  • Home
  • Product
  • Features
  • Documentation
  • Download
  • Pricing
  • Support
  • Documentation
  • Videos
  • FAQ
  • Learn Python
  • Contact Us
  • About
  • About Us
  • Legal
  • Blog
© Copyright PyXLL Ltd