Jump to content

Recommended Posts

Posted

Hello, I am trying to figure out if it's possible to programmatically call the "Export table" menu item that appears when the user right-clicks on a Table visualization onthe WebPlayer.

The reason I am trying to do that is I am trying to develop a CustomTool C# extension to download the data that is currently shown in a Map chart. To do that, the current implementation converts a Map chart to a Table so I can call its ExportData method. However, that method requires a FileStream which requires a path. If I use the current implementation the logic tries to save the resulting file on the WebPlayer's server and not stream it down to the user's browser.

 

So I am thinking if there is a way to execute the "Export table" context menu item that is already build-in to Spotfire WebPlayer from code. The method downloads the resulting Excell file to the user (i.e. normal browser download behaviour).

 

 

Current snippet of code in my CustomTool:

protected override void ExecuteCore(VisualContent map)

{

map.Transactions.BeginAggregatedTransaction();

 

var doc = map.Context.GetAncestor();

AggregatedTransactionHandle transaction = doc.Transactions.BeginAggregatedTransaction();

 

doc.Transactions.ExecuteTransaction(delegate

{

var visual = map.Visual;

visual.TypeId = VisualTypeIdentifiers.Table;

var table = visual.As();

 

var dm = doc.Data.Markings.DefaultMarkingReference;

table.Data.Filterings.Add(dm);

 

var pathWithEnv = @"%UserProfile%DesktopExportData.xls";

var filePath = Environment.ExpandEnvironmentVariables(pathWithEnv);

 

if (!Directory.Exists(filePath))

{

Directory.CreateDirectory(filePath);

}

 

using (FileStream stream = File.Open(filePath, FileMode.Create))

{

table.ExportData(DataWriterTypeIdentifiers.ExcelXlsDataWriter, stream);

}

});

 

transaction.Rollback();

}

Posted

It might not be possible to trigger the export table UI functionality. Have you looked into developing a CustomExportTool instead of a CustomTool This will give you the ability to download the file on to users machine.

https://community.spotfire.com/wiki/create-custom-export-tool-tibco-spotfire

You can refer to the HTMLPrintTool example in the SDK which has the above implementation.

Or one other approach is to provide a UNC path in the custom tool where the user has access to so that they can access the file once exported.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...