Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
Handle table exports containing cells with more than 65K characters using the API
Solution:
All exports in Spotfire done from the visualizations will go through formatting, and the default behavior of string formatting is to truncate very long strings. This means that all table cells that are exported to CSV will be truncated after 65535 characters.
The normal API export also use the default string formatter and truncate the exported values.
The solution is to use another part of the API to export the content of the cell. This is done with the GetRows function.
https://docs.tibco.com/pub/doc_remote/spotfire/7.6.0/doc/api/?topic=html/M_Spotfire_Dxp_Data_DataTable_GetRows_1.htm
API Reference Example:
DataTable table; DataValueCursor<int> cursor1 = DataValueCursor.Create<int>(table.Columns["Column1"]); DataValueCursor<double> cursor2 = DataValueCursor.CreateNumeric(table.Columns["Column2"]); DataValueCursor<string> cursor3 = DataValueCursor.CreateFormatted(table.Columns["Column3"]); DataSelection selection; foreach (DataRow row in table.GetRows(selection, cursor1, cursor2, cursor3)) { int rowIndex = row.Index; int value1 = cursor1.CurrentValue; double value2 = cursor2.CurrentValue; string value3 = cursor3.CurrentValue; DoSomething(rowIndex, value1, value2, value3); }
After we have the lists of the values we need to build the final export file using the .NET libraries. We cannot use the Spotfire API for this since the values will then be truncated. The standard StreamWriter class should be fine for this purpose.
https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx
GetRows API:
https://docs.tibco.com/pub/doc_remote/spotfire/7.6.0/doc/api/?topic=html/M_Spotfire_Dxp_Data_DataTable_GetRows_1.htm
StreamWriter:
https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx
Comments
0 comments
Article is closed for comments.