Neha arora
Neha arora

Reputation: 65

Export to Excel not working with more than two s:optiontransferselect

I am getting a strange problem. Below code works fine if I used any two <s:optiontransferselect>, but when I add third <s:optiontransferselect>, export to excel functionality of displayTag does not work.

JSP:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
function openPopUp(){
    document.getElementById('bankForm').setAttribute('target', '_blank');
    document.getElementById('bankForm').setAttribute('action', 'displayBankChartAction.action');
}
function noPopUp(){
    document.getElementById('bankForm').setAttribute('target', '');
}
</script>
<s:head theme="ajax" debug="true"/>
<link rel="stylesheet" href="gebMi.css" type="text/css" />
<title>Insert title here</title>
</head>
<body>
<s:form id="bankForm">
<img src="images/eb.jpg" alt="Electronic Bannking" style="width:60%;height:10%">
<div class='statusbar'>Bank Info</div>
<table>
<tr>
<td>
      <s:datetimepicker label="Select From" name="bankBean.fromDate" displayFormat="dd-MM-yy"/>
      </td>
      <td>  
      <s:datetimepicker label="Select To" name="bankBean.toDate" displayFormat="dd-MM-yy" />
      </td>
      </tr>
</table>
<table>
<tr>
<td>
      <s:optiontransferselect
        label="Channels"
        name="bankBean.leftChannels"
        leftTitle="Unselected Channels"
        rightTitle="Selected Channels"
        list="bankBean.leftChannelsList"
        multiple="true"
        headerKey="-1"
        doubleList="bankBean.rightChannelsList"
        doubleName="bankBean.rightChannels"
        doubleHeaderKey="-1"
        doubleHeaderValue="Selected Values"
      /> 
      </td>
      
      <td>
      
      <s:optiontransferselect
      
        label="Transaction Types"
        name="bankBean.leftTransTypes"
        leftTitle="Unselected Transaction Types"
        rightTitle="Selected Transaction Types"
        list="bankBean.leftTransTypesList"
        multiple="true"
        headerKey="-1"
        doubleList="bankBean.rightTransTypesList"
        doubleName="bankBean.rightTransTypes"
        doubleHeaderKey="-1"
        doubleHeaderValue="Selected Values"
      />  
      </td>
      <td>
      
      <s:optiontransferselect
      
        label="Bics"
        name="bankBean.leftBics"
        leftTitle="Unselected Bics"
        rightTitle="Selected Bics"
        list="bankBean.leftBicsList"
        multiple="true"
        headerKey="-1"
        doubleList="bankBean.rightBicList"
        doubleName="bankBean.rightBics"
        doubleHeaderKey="-1"
        doubleHeaderValue="Selected Values"
      />  
      </td>
      </tr>
     </table>  
<div style="display:<s:property value= "%{displayTable}"/>">
     <display:table class="bb" export="true" id="dTable" name="listBankBean" cellspacing="2px;" cellpadding="2px"  style="margin-left:10px;margin-top:20px;" requestURI="">
            <display:column property="dateTime" title="DateTime" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
            <display:column property="channel" title="Channel" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
            <display:column property="transactionType" title="Transaction Type" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
            <display:column property="bic" title="Bic" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
            <display:column property="volume" title="Volume" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
            <display:footer media="all"> 
            <tr style="border: 1px solid #B0B0B0;">
                <td colspan="4">Total</td>
                <td><s:property value= "%{grandTotal}"/></td>
            </tr> 
            </display:footer> 
            
    </display:table>
        
    </div>  
      <table>
      <tr>
        <td>
            <s:submit value="Show Chart" align="center" onclick="openPopUp();" />
        </td>
        <td>
            <s:submit value="Fetch Data" align="center" action="displayBankDataAction" onclick="noPopUp();" />
        </td>
      </tr>
     </table>

</s:form>
</body>
</html>

Upvotes: 0

Views: 557

Answers (1)

Roman C
Roman C

Reputation: 1

The only exporter knows how many columns in the display table. But it can't calculate a number of columns in the footer. The value of spans should be equal to the number of columns for the valid HTML table.

 <display:table class="bb" export="true" id="dTable" name="listBankBean" cellspacing="2px;" cellpadding="2px"  style="margin-left:10px;margin-top:20px;" requestURI="">
        <display:column property="dateTime" title="DateTime" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
        <display:column property="channel" title="Channel" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
        <display:column property="transactionType" title="Transaction Type" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
        <display:column property="bic" title="Bic" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
        <display:column property="volume" title="Volume" headerClass="header1" style="border: 1px solid #B0B0B0;"/>
        <display:footer media="all"> 
        <tr style="border: 1px solid #B0B0B0;">
            <td colspan="5">Total</td>
            <td><s:property value= "%{grandTotal}"/></td>
        </tr> 
        </display:footer> 

</display:table>

Upvotes: 0

Related Questions