title: Xpage call the agent to export excel
body: <p>I found the code on this website: <a href="http://www.botstation.com/code/view2excelweb.php" rel="nofollow">http://www.botstation.com/code/view2excelweb.php</a></p>
  
  <p>It mentioned the agent can export views in excel format, so I tried to use it.</p>
  
  <p>I created an agent called "AgentTest" and paste the code inside.</p>
  
  <p>I used a button to call the agent to perform the action.</p>
  
  <p>This code set on click event (server side) for the button:</p>
  
  <pre><code>database.getAgent("AgentTest").run()
  </code></pre>
  
  <p>For the agent Basics part, I set the Runtime Trigger is "On event", Agent list selection and the Target is "None".</p>
  
  <p>For the agent Security part, I checked the checkbox "Run as Web user" and choose " 2. Allow restricted operations" for the Runtime security level.</p>
  
  <p>I saved everything and run the code, but I did not get excel file.</p>
  
  <p>I tried to find out the problem use Debug LotusScript from Tools , however nothing happen when I click the button.</p>
  
  <p>Grateful for your advice on this issue.</p>
  
  <p>Thank you very much.</p>
  
  <p>Yours faithfully,</p>
  
  <p>beginner</p>
  
  <p>(Edit for update)</p>
  
  <p>I would like to ask one more question base on this website <a href="http://www.botstation.com/code/view2excelweb.php" rel="nofollow">http://www.botstation.com/code/view2excelweb.php</a> please.</p>
  
  <p>Since the agent needs to call by URL, the website has been given an example: 
  <a href="http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&amp;ViewNameToExport" rel="nofollow">http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&amp;ViewNameToExport</a></p>
  
  <p>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.</p>
  
  <p>In the button, in Events, I choose Mouse onclick and put this code in the Script Editor:</p>
  
  <pre><code>print('http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&amp;ViewNameToExport');
  </code></pre>
  
  <p>The Internet Explorer shows the error "The website cannot display the page".</p>
  
  <p>I also try this code for the button:</p>
  
  <pre><code>window.open('http://ServerName/YourDatabase.nsf/WebAgentName?OpenAgent&amp;ViewNameToExport');
  </code></pre>
  
  <p>The Internet Explorer still shows the error.</p>
  
  <p>I don't know why the error occurs. I visit this website <a href="http://www.w3schools.com/jsref/met_win_open.asp" rel="nofollow">http://www.w3schools.com/jsref/met_win_open.asp</a> . The code should be fine if I use window.open. </p>
  
  <p>My idea in the code is to display the URL in the window that ask me to open or save the excel file. </p>
  
  <p>Grateful for your advice on this issue please.</p>
  
  <p>Sorry for the inconvenience.</p>
  
  <p>Thank you very much.</p>