cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CSV File Creation

Former Member
0 Kudos
212

I have an app that I want to allow the end user generate a report (irpt window) or a csv file not utilizing the BLS. Does anyone have any suggestions as to how I can open up a page that is already formated as a csv grid, much like when you right click on a chart and request the data/csv file option? I want to do this by providing the user some areas to enter parameters and to click a button that generates/opens the csv file page.

Any assistance would be appreciated.

Thanks,

Larry

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can do this one of two ways (may be more):

1) Use the saveAsCSVFile() method for a grid or chart. If you don't want to see the applet on the page, just hide by giving it a 1x1 width and height. The user would click a button that calls a JS function to the document.myApplet.saveAsCSVFile() method.

2) Build a URL and open a new window to the URL that calls the Servlet page. Set the content-type of the servlet to text/csv. I'll see if I can dig up an example of this.

Former Member
0 Kudos

Ryan,

Thanks for your reply. I am definitely interested in your solution #2. Right now, my app allows the user to enter a series of paramters and then I provide 2 buttons. One button opens a page in an irpt format that they can view/print. The other button I want to open a page in a csv format to allow the user to save and work with in excel. If you have an example of a method of putting the correct servlet in a url, that would work great.

Thanks,

Larry

Former Member
0 Kudos

On the page that the user enters a series of parameters, use Javascript (on a button event) to build the URL of the new page (with the Servlet). You are probably doing something similar now to open the irpt in a new window:


var myUrl = "myPage.irp?";
myUrl += "myParam1=" + selParam1;
myUrl += "myParam2=" + selParam2;
...
window.open(myUrl);

Then, on the new window, you can have an applet with a 1x1 dimension that you pass the parameters into. On that applet have a First Update Event that calls its own saveAsCSVFile() method. If you want to display the information on the new window and allow the user to export to CSV just resize the Applet to a viewable size.

If you'd rather show the data as an HTML table for example, try doing a Servlet AND an applet in the new window like this:


<SERVLET NAME="Illuminator">
<HR>
Illuminator Content Here
<HR>
<PARAM NAME="QueryTemplate" VALUE="myFolder/myQuery">
<PARAM NAME="StyleSheet" VALUE="http://localhost/myFolder/myReport.xsl">
<PARAM NAME="Content-Type" VALUE="text/xml">
<PARAM NAME="Param.1" VALUE="{myParam1}">
<PARAM NAME="Param.2" VALUE="{myParam2}">
...
<PARAM NAME="StartDate" VALUE="{SD}">
<PARAM NAME="EndDate" VALUE="{ED}">
</SERVLET>

Former Member
0 Kudos

Thanks Ryan,

I actually went back to your previous response and took option 1 and added a hidden grid to the page and used the saveAsCSVFile() method. Option 2 created 2 popup pages which became confusing.

Thanks for your help.

Larry

Answers (0)