Switch Map chart to CrossTable; execute ExportText all in memory?

Hello, I am wondering if it's possible to convert the Map chart to CrossTable (I need to execute the ExportText method that is part of the CrossTable class) in memory? I don't want to "visually" change the Analysis's page, the only reason I want to convert the above visualizations is to be able to execute the ExportText method.



The code below does work but it switches the visualizations. Any ideas?



 

from System.IO import Path, File, StreamWriter
from Spotfire.Dxp.Application.Visuals import *

for vis in Document.ActivePageReference.Visuals: 
	if vis.TypeId == VisualTypeIdentifiers.MapChart2:

		vis.TypeId = VisualTypeIdentifiers.CrossTable
		ct = vis.As[CrossTablePlot]()  
		writer = StreamWriter("C:\\Users\\user\\Desktop\\GDAta.txt")
		ct.ExportText(writer)
		print("Export done")
		vis.TypeId = VisualTypeIdentifiers.MapChart2
		vis.As[MapChart]()  

 

Login