从面板导出数据 [英] export data from panel

查看:26
本文介绍了从面板导出数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了 David Leedy 关于Export to excel.的这个非常有用的工具":

I read this great help 'tool' from David Leedy regarding Export to excel.:

http://notesin9.com/wp-content/uploads/2011/01/XPagesCheatSheet-85x11-v1.pdf

我的场景:我有一个 ftsearch 模数,它将结果提供到一个视图面板中.我只想将这些结果导出到 excel 中.我按照 .pdf 中的步骤操作,但在这种情况下,它将导出相应视图中列出的所有文档,而不是搜索结果.

My scenario: I have a ftsearch modulo which offers its results into a viewpanel. I want ONLY those results to be exported into excel. I follow the steps from the .pdf but in that case it will export all the documents listed in the respective view, not the search results.

提交搜索后,有没有可能只将搜索结果存入excel文件?

Is there any possibility to have only the search results into the excel file, after the search is submited?

var myView:NotesView = database.getView('MyView');

在这里,我获得了包含搜索结果的视图,但我想获得视图内容/那些文档.Search 按钮提交后.问题是我没有只看到搜索结果的更新"视图,而是该视图中包含的所有 DOCS.(在点击 Search 按钮之前...)

Here I get the view which holds the search results, but I want to get the view contents/those docs. after the Search button was submitted. The problem is I don't get the 'updated' view only with the search results, but all the DOCS contained in that view. ( Before the Search button was clicked ... )

感谢您的时间!

推荐答案

您说您已经有一个显示搜索结果的视图面板.我假设您使用视图面板对象上的 search 属性来执行此操作.另一个假设是,您正在根据绑定到作用域变量(可能是 sessionScope)的输入字段计算 search 属性中的全文查询.因此,您在搜索 XPage 上的数据源将如下所示:

You say that you already have a view panel that shows the search results. I'm assuming that you're using the search attribute on the view panel object to do that. Another assumption is that you're computing the full text query in the search attribute based on an input field that's bound to a scoped variable (possibly the sessionScope). So your datasource on the search XPage would look something like this:

<xp:this.data>
  <xp:dominoView
    var="view1"
    viewName="yourSearchView">
    <xp:this.search><![CDATA[#{javascript:"[subject]=\"" + sessionScope.searchField + "*\"";}]]></xp:this.search>
  </xp:dominoView>
</xp:this.data>

在导出 XPage 中,您可以在导出结果之前通过对视图应用相同的查询来限制导出的条目.为此,您可以在视图上使用FTSearch()"函数:

In the Export XPage you can restrict the entries that are exported by applying the same query to the view before exporting the results. To do that you can use the 'FTSearch()' function on the view:

myView.FTSearch("[subject]=\"" + sessionScope.searchField + "*\");

基于 David 的备忘单上的代码,我对此进行了测试,结果表明,由于某些原因,如果您添加此行,则基于(过滤的)视图构建的 NotesViewNavigator 不受限制到搜索结果,但仍包含所有条目.解决方案是删除 NotesViewNavigator 对象并使用 NotesViewEntryCollection:

Based on the code on David's cheatsheet I tested this and it turns out that for some reasons if you add this row, the NotesViewNavigator that is constructed based on the (filtered) view isn't limited to the search results, but still contains all entries. The solution to that is to remove the NotesViewNavigator object and use a NotesViewEntryCollection:

var exCon = facesContext.getExternalContext(); 
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();

var myView:NotesView = database.getView('vwKlanten');
var query = "[subject]=\"em*\"";
myView.FTSearch(query);

var vec:NotesViewEntryCollection = myView.getAllEntries()

var viewEnt:NotesViewEntry = vec.getFirstEntry();

response.setContentType("application/vnd.ms-excel");
response.setHeader("Cache-Control", "no-cache");

writer.write("<table>");
writer.write("<thead><tr>");
writer.write("<td><b>Column1Header</b></td>");
writer.write("<td><b>Column2Header</b></td>");
writer.write("<td><b>Column3Header</b></td>");
writer.write("</tr></thead>");

while (viewEnt != null) {

 writer.write("<tr>");
 writer.write("<td>" + viewEnt.getColumnValues()[0] + "</td>");
 writer.write("<td>" + viewEnt.getColumnValues()[1] + "</td>");
 writer.write("<td>" + viewEnt.getColumnValues()[2] + "</td>");
 writer.write("</tr>");

 var tmp = vec.getNextEntry(viewEnt);
 viewEnt.recycle();
 viewEnt = tmp;
}

writer.write("</table>");
writer.endDocument();

(顺便说一句:我添加了一个 'recycle()' 调用来处理可能的内存错误)

(BTW: I added a 'recycle()' call to deal with possible memory errors)

这篇关于从面板导出数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆