简体   繁体   English

xpages:是否可以将数据动态导出到Excel(取决于用户的选择)?

[英]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)? 请问是否可以将数据动态导出为Excel(取决于用户的选择)?

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. 假设用户测试001属于组B,并且用户想要分配给组D,则用户单击“提交”按钮,程序将把用户定向到下一页。

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. 该表将显示与将来的组(组D)相关的活动列表,用户可以查看哪些活动已加入日期和哪些活动未加入。

在此处输入图片说明

The user is allowed to export the result to excel by click the export button. 通过单击导出按钮,允许用户将结果导出到excel。

The excel will probably look like this: excel可能看起来像这样:

在此处输入图片说明

We use an agent to export the excel file. 我们使用代理导出excel文件。

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. 但是,当我们运行代理时,excel看起来很奇怪。

在此处输入图片说明

Due to our team is not good at develop xpages application, I should be grateful if you would give advice on these questions please. 由于我们的团队不擅长开发xpages应用程序,如果您能对这些问题提出建议,我将不胜感激。

  1. Is it possible to implement the whole scenario in xpages? 是否可以在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? 我们确信我们将在xpages中开发出很多类似这种情况的任务,那么有什么方法可以动态导出数据以实现excel?

  3. Our agent can export the excel file but the excel looks very strange, is something wrong in our code? 我们的代理可以导出excel文件,但是excel看起来很奇怪,我们的代码有问题吗?

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 . 看一下以下OpenNTF Project POI 4 XPages

The key benefits: 主要优点:

  • Apache POI is a very good open source project. Apache POI是一个非常好的开源项目。 I have it in use for many years without any troubles. 我已经使用了很多年,没有任何麻烦。
  • You can write your code in Java 您可以用Java编写代码
  • You can implement the whole scenario in XPages (eg do it with an XAgent which can work on the selected documents) 您可以在XPages中实现整个方案(例如,使用可以处理所选文档的XAgent来实现)

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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