Bill Koppelman Posted October 1, 2021 Share Posted October 1, 2021 I am using the IronPython code from the solution here:https://community.spotfire.com/questions/exporting-data-tables-cross-or-modified-calculated-columns-excelcsv to export my cross table to excel. However, when I open the excel file, I get an error (pic attached) that says the file is corrupted or unsafe. When I click yes to open it anyways, the data is all there in working order. Is there something wrong in the code that is causing this error import System from System.IO import FileStream, FileMode from Spotfire.Dxp.Application.Visuals import TablePlot from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import SaveFileDialog SaveFile = SaveFileDialog() SaveFile.Filter = "Excel Workbook (*.xls)|*.xls" SaveFile.ShowDialog() saveFilename = SaveFile.FileName from Spotfire.Dxp.Application.Visuals import VisualContent,TablePlotColumnSortMode from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers from System.IO import File, StreamWriter writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter) stream = StreamWriter(saveFilename) te = crossTable.As[VisualContent]() te.ExportText(stream) Link to comment Share on other sites More sharing options...
Brian Winter Posted June 30, 2023 Share Posted June 30, 2023 I have the same issue (with identical code), but haven't found the error either. Link to comment Share on other sites More sharing options...
Adam Posted February 12 Share Posted February 12 Hello, I think it has to do with the line: writer = Document.Data.CreateDataWriter(DataWriterTypeIdentifiers.ExcelXlsDataWriter) This writer is not referenced again, instead the StreamWriter is used to export the data. I'm struggling with the same error and do not know the solution. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now