Reputation: 190
I found the code on this website: http://www.botstation.com/code/view2excelweb.php
It mentioned the agent can export views in excel format, so I tried to use it.
I created an agent called "AgentTest" and paste the code inside.
I used a button to call the agent to perform the action.
This code set on click event (server side) for the button:
database.getAgent("AgentTest").run()
For the agent Basics part, I set the Runtime Trigger is "On event", Agent list selection and the Target is "None".
For the agent Security part, I checked the checkbox "Run as Web user" and choose " 2. Allow restricted operations" for the Runtime security level.
I saved everything and run the code, but I did not get excel file.
I tried to find out the problem use Debug LotusScript from Tools , however nothing happen when I click the button.
Grateful for your advice on this issue.
Thank you very much.
Yours faithfully,
beginner
(Edit for update)
I would like to ask one more question base on this website http://www.botstation.com/code/view2excelweb.php please.
Since the agent needs to call by URL, the website has been given an example: http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport
I copy the URL and paste in Internet Explorer, the link can allow me to save or open the excel file. So I start to think to use the button to open the URL.
In the button, in Events, I choose Mouse onclick and put this code in the Script Editor:
print('http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport');
The Internet Explorer shows the error "The website cannot display the page".
I also try this code for the button:
window.open('http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport');
The Internet Explorer still shows the error.
I don't know why the error occurs. I visit this website http://www.w3schools.com/jsref/met_win_open.asp . The code should be fine if I use window.open.
My idea in the code is to display the URL in the window that ask me to open or save the excel file.
Grateful for your advice on this issue please.
Sorry for the inconvenience.
Thank you very much.
Upvotes: 0
Views: 644
Reputation: 30960
Use HTML <a> href Attribute
to run the agent and save/open the Excel file
<a href="http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&ViewNameToExport">Excel file</a>
Upvotes: 0
Reputation: 3484
It's not possible to print the output of an Lotusscript agent that way in XPages. If you want to print the output of the Lotusscript agent you need to send the user in the same window or a new window directly to the Lotusscript agent.
But I would really encurage you that you need to check out POI Check that your version of Domino is correct for installing POI for XPages Also if you are using 9.0.1 there is some Java issues with installing thru updatesites. Make sure that you have installed the latest fixpacks to the client.
I've created a blog series about how to do excel export using POI
Upvotes: 2