How to use Application.ShowChartTipValues in the xlwings API way

In the Excel object model, the Application.ShowChartTipValues property is a member of the top-level Application object. This property controls whether chart tip values (also known as data labels or tooltips) are displayed when you hover the mouse pointer over a data point in a chart within Excel. When enabled, users can see the exact numeric value of a data point directly on the chart, enhancing data visualization and analysis. This setting applies globally to all open workbooks in the Excel instance.

In xlwings, you can access and manipulate this property through the api property of the App object, which provides a direct gateway to the underlying Excel Application object via the COM interface. The xlwings API call follows the pattern: app.api.ShowChartTipValues, where app is an instance of xlwings.App. This property is a Boolean value, meaning it can be set to True to enable chart tip values or False to disable them. You can also retrieve its current state to check if the feature is active.

The syntax for using ShowChartTipValues in xlwings is straightforward:

  • To get the current setting: current_setting = app.api.ShowChartTipValues
  • To set the setting: app.api.ShowChartTipValues = True or app.api.ShowChartTipValues = False

There are no parameters for this property, as it is a simple Boolean attribute. However, it’s important to note that changes made to this property affect the entire Excel application session. This means that all charts across all open workbooks will adhere to this setting until it is changed again or Excel is closed. It’s a useful feature for presentations or reports where you might want to temporarily hide or show data values for clarity.

Here is a practical xlwings API code example that demonstrates how to use the ShowChartTipValues property:

import xlwings as xw

# Connect to the active Excel instance or start a new one
app = xw.apps.active if xw.apps.active else xw.App()

# Get the current state of ShowChartTipValues
current_state = app.api.ShowChartTipValues
print(f"Current ShowChartTipValues setting: {current_state}")

# Disable chart tip values
app.api.ShowChartTipValues = False
print("Chart tip values have been disabled.")

# Perform some chart-related operations, e.g., open a workbook with a chart
wb = app.books.open('example.xlsx')
chart = wb.sheets[0].charts[0] # Assuming the first chart on the first sheet
# At this point, hovering over chart data points will not show values

# Re-enable chart tip values
app.api.ShowChartTipValues = True
print("Chart tip values have been re-enabled.")

# Close the workbook without saving
wb.close()

# Optionally, reset to the original state if needed
app.api.ShowChartTipValues = current_state

# Quit the Excel application if it was started by this script
if not xw.apps.active:
app.quit()

July 14, 2026 (0)


Leave a Reply

Your email address will not be published. Required fields are marked *