简体   繁体   中英

xpages: is it possible to export data to excel dynamically (depends on user's selection)?

May I ask is it possible to export data to excel dynamically (depends on user's selection)?

Imagine the following scenario:

The user login to the program, it will display the user name (member), the group that user currently belongs to and the user is allow to choose the future group that wants to assign.

在此处输入图片说明

Suppose a user test 001 belongs to Group B and the user wants to assign to Group D, the user clicks the Submit button, the program will direct the user to the following page.

The page will display the result.

The table will show a list of activity that related to the future group(Group D), the user can see which activity is joined with the joined date and which activity is not join.

在此处输入图片说明

The user is allowed to export the result to excel by click the export button.

The excel will probably look like this:

在此处输入图片说明

We use an agent to export the excel file.

Here is our code:

Sub Initialize
Print |Content-Type:application/vnd.ms-excel| 


Print "<tr><td>Result<br></td></tr>"
Print "<br>"
Print "<tr><td>Member</td><td>Test 001</td></tr>"
Print "<br>"
Print "<table border = 1><tr><th>Activity</th><th>Joined</th></tr>"
Print "<tr><td>Activity 1</td><td>Yes</td></tr>"
Print"<tr><td>Activity 2</td><td>No</td></tr>"
Print "<tr><td>Activity 3</td><td>No</td></tr>"
Print "<tr><td>Activity 4</td><td>Yes</td></tr>"
Print "<tr><td>Activity 5</td><td>No</td></tr>"
Print "<tr><td>Activity 6</td><td>No</td></tr></table>"
Print "<br>"
Print "<tr><td>Activity Joined</td><td>2</td></tr><br>"
Print "<tr><td>Activity Not Joined</td><td>4</td></tr><br>"


End Sub

However when we run the agent, the excel looks strange.

在此处输入图片说明

Due to our team is not good at develop xpages application, I should be grateful if you would give advice on these questions please.

  1. Is it possible to implement the whole scenario in xpages?

  2. We are sure that we will have lots of task like this scenario develop in xpages, so is there any way to export data to excel dynamically?

  3. Our agent can export the excel file but the excel looks very strange, is something wrong in our code?

Sorry for my bad English and I appreciate any advice. Thank you very much.

Take a look at the following OpenNTF Project POI 4 XPages .

The key benefits:

  • Apache POI is a very good open source project. I have it in use for many years without any troubles.
  • You can write your code in Java
  • You can implement the whole scenario in XPages (eg do it with an XAgent which can work on the selected documents)

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM