# Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
from System.IO import *
from Spotfire.Dxp.Application.Visuals import VisualContent
vc=Visuals.As[VisualContent]() #Visuals = Script parameter for Table/Cross Table visualization
memStream = MemoryStream();
sWriter = StreamWriter(memStream);
#Exporting the data to Memory Stream
vc.ExportText(sWriter); #exports data in tab separated text
sReader = StreamReader(memStream);
memStream.Seek(0, SeekOrigin.Begin);
filename="C:\WebPlayer\spotfireexport.csv"
f=open(filename,"w")
f.write('This report is provided to support ABC project. \n\n')
counter=0
j=0
str1=''
while (sReader.Peek()>=0):
line=[]
counter=counter+1 #counts the number of rows in dataset
a=sReader.ReadLine()
lines=a.split("\t")
for elem in lines:
j=j+1 # counts the number of columns in dataset
print elem
if str(elem).find(",")<>-1:
elem='"'+elem+'"' # escaping comma already present in string
line.append(elem)
str1 = ','.join(str(e) for e in line)
f.write(str1+'\n')
f.close();
MemoryStream.Dispose(memStream);
sReader.Close()
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
html = None
for vis in Document.ActivePageReference.Visuals:
if vis.Title == 'HTML':
html = vis.As[HtmlTextArea]()
html.HtmlContent = '
Click here to download CSV'
from System.IO import *
from Spotfire.Dxp.Application.Visuals import VisualContent
vc=Visuals.As[VisualContent]() #Visuals = Script parameter for Table/Cross Table visualization
memStream = MemoryStream();
sWriter = StreamWriter(memStream);
#Exporting the data to Memory Stream
vc.ExportText(sWriter); #exports data in tab separated text
sReader = StreamReader(memStream);
memStream.Seek(0, SeekOrigin.Begin);
filename="C:\WebPlayer\spotfireexport.csv"
f=open(filename,"w")
f.write('This report is provided to support ABC project. \n\n')
counter=0
j=0
str1=''
while (sReader.Peek()>=0):
line=[]
counter=counter+1 #counts the number of rows in dataset
a=sReader.ReadLine()
lines=a.split("\t")
for elem in lines:
j=j+1 # counts the number of columns in dataset
print elem
if str(elem).find(",")<>-1:
elem='"'+elem+'"' # escaping comma already present in string
line.append(elem)
str1 = ','.join(str(e) for e in line)
f.write(str1+'\n')
f.close();
MemoryStream.Dispose(memStream);
sReader.Close()
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
html = None
for vis in Document.ActivePageReference.Visuals:
if vis.Title == 'HTML':
html = vis.As[HtmlTextArea]()
html.HtmlContent = '
Click here to download CSV'
No comments:
Post a Comment