单击按钮以在XPages中导出Excel [英] Onclick the button to export excel in XPages

查看:73
本文介绍了单击按钮以在XPages中导出Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上找到了代码: https://www.xpagedomino.com/2015/02/xpage-export-to-excel-using-javascript.html

I found the code on the website: https://www.xpagedomino.com/2015/02/xpage-export-to-excel-using-javascript.html

现在我有:

  1. 视图
  2. 一个按钮


我想使用按钮导出Excel.


I want to use the button to export the excel.

以下是我已经尝试过的代码:

The following is I already tried the code:

在按钮(客户端)中:

var viewPanel1Id = "view:_id1:viewPanel1"
var htmltable = document.getElementById(viewPanel1Id);
var html = htmltable.outerHTML;
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));

但是按钮没有响应...

But the button was no response...

我如何导出到excel ?????

How can I export to excel?????

以下是XPages的代码

The following is the code of XPages

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:button value="Export5" id="button5">
    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action><![CDATA[#{javascript: var viewPanel = document.getElementById("#{id:viewPanel1}");
 var html = viewPanel.outerHTML;
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));}]]>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:viewPanel rows="30" id="viewPanel1" viewStyle="width:100%">
        <xp:this.facets>
            <xp:pager partialRefresh="true" layout="Previous Group Next"
                xp:key="headerPager" id="pager1">
            </xp:pager>
        </xp:this.facets>
        <xp:this.data>
            <xp:dominoView var="view1" viewName="VEMPM03"></xp:dominoView>
        </xp:this.data>
        <xp:viewColumn columnName="LOCAL_PR_NO" id="viewColumn1"
            showCheckbox="true">
            <xp:viewColumnHeader value="prno" id="viewColumnHeader1"
                showCheckbox="true">
            </xp:viewColumnHeader>
        </xp:viewColumn>
        <xp:viewColumn columnName="PUR_DEPT_S01" id="viewColumn2">
            <xp:viewColumnHeader value="pur" id="viewColumnHeader2">
            </xp:viewColumnHeader>
        </xp:viewColumn>
        <xp:viewColumn columnName="ITEM_NAME" id="viewColumn3">
            <xp:viewColumnHeader value="name" id="viewColumnHeader3">
            </xp:viewColumnHeader>
        </xp:viewColumn>
    </xp:viewPanel>
</xp:view>

推荐答案

您的按钮执行ServerSide脚本.使用< xp:this.script>时它对我有用.

Your Button executes ServerSide Script. When using <xp:this.script> it worked for me.

    <xp:button value="Export5" id="button5">
      <xp:eventHandler event="onclick" submit="false">
        <xp:this.script><![CDATA[ 
                var viewPanel = document.getElementById("#{id:viewPanel1}");
                var html = viewPanel.outerHTML;
                window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));]]>
  </xp:this.script>
    </xp:eventHandler>
</xp:button>

这篇关于单击按钮以在XPages中导出Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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