How to export Spotfire crosstable (visualization) to Excel as xlsx file (NOT XLS)

I am trying to export Spotfire crosstable to excel as a xlsx file. I know how to perform this process with csv files. However, I get this error "file format or file extension is not valid" everytime I export the crosstable into excel. Background info: I have a visualization called "CrossTable".

Any help would be appreciated, thank you! 

import System
import clr
from System.IO import FileStream, FileMode, File, StreamWriter
from Spotfire.Dxp.Application.Visuals import TablePlot,VisualContent,TablePlotColumnSortMode
from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
from System.Windows.Forms import SaveFileDialog

SaveFile = SaveFileDialog()
SaveFile.FileName = "Crosstable.xlsx"
SaveFile.Filter = "Excel Workbook (*.xlsx)|*.xlsx" 
saveFilename = SaveFile.FileName

writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsxDataWriter) 
stream = StreamWriter(saveFilename)
te = CrossTable.As[VisualContent]()