0

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.

beginner
  • 192
  • 1
  • 1
  • 13
  • Either rewrite the Lotusscript to proper Java (btw. the agent has to be called by URL , not by agent.run() ) or have a look at http://poi4xpages.openntf.org/ – umeli Sep 30 '15 at 07:36
  • Hello @umeli , thank you for your reply. I tried to install POI 4 but I got the error in site.xml. The website I mention in the post seems similar to POI 4 so I may search the method to call the agent by URL. Thank you very much. – beginner Sep 30 '15 at 08:13
  • I wrote a few blog posts about exporting to Excel from XPages http://lostinxpages.com/tag/excel/ – David Navarre Nov 03 '15 at 12:32
  • @ David Navarre, thank you for your posts sharing. – beginner Nov 23 '15 at 03:20

2 Answers2

2

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

POI for XPages the series

Fredrik Norling
  • 3,461
  • 17
  • 21
  • Hello @Fredrik Norling , thank you for your reply. In my another post about POI 4 installation (http://stackoverflow.com/questions/32736668/poi-4-xpages-installation-site-xml), I asked the domino-administrator for the version of the domino designer and the client. I received the reply is both of them are in the latest version. However, I am not sure whether the fixpacks are installed or not. So I may confirm the domino designer about this issue. Last but not least, I appreciate for your suggestion. Thank you very much – beginner Sep 30 '15 at 09:42
  • 2
    Actually you kind of can. You need to search/replace a little. See http://www.wissel.net/blog/d6plinks/SHWL-8SF7AH - but I would rather use Java and the POI path. It would allow to even export formula, something the HTML trick doesn't do – stwissel Sep 30 '15 at 10:11
  • 1
    Your other alternative, not always recommended these days, is to create a xAgent to create your Excel file from your datasource. I recently started a blog series on this myself, but have one more part to write. However, you can find a multitude of others that have posted about this. Nowadays, it seems Apache POI is the recommended means of creating an Excel file. – Dwain Wuerfel Sep 30 '15 at 10:12
0

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>
Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67