Skip to main content

Script Tip Friday- Displaying txt, PDF or browser contents in your worksheet

| 06.24.2022

Our Script Tip this week comes from our Senior Application Engineer here at Ansys, Vishnu Venkataraman. Have you ever wondered the best way to display text, PDF or browser contents in your worksheet? Well thank goodness we have Vishnu here to help!

"Some examples you may want to display in your worksheet:

PDF Content:

Text File:

Web Content:

Worksheet uses HTML templates to display contents in worksheet. HTML templates to display are stored in below path for version 22.1:

C:\Program Files\ANSYS Inc\v221\aisol\DesignSpace\DSPages\html

Hence, you can use the below code to display web, txt or pdf contents:

import toolbar
toolbar.ToggleWorksheetVisibility(ExtAPI)
WorksheetPane = ExtAPI.UserInterface.GetPane(MechanicalPanelEnum.Worksheet)
WorksheetPane.Caption = "my content"
WorksheetPane.CloseButtonVisible = True
control = WorksheetPane.ControlUnknown
control.Navigate(r"Your\path\to\text\file\mytext.txt") #for Text content
#control.Navigate(r"Your\path\to\pdf\file\mypdf.pdf")#for PDF content
#control.Navigate("www.google.com")#for web content