Export to excel only visible columns not working

Export to excel only visible columns not working

TanajiTanaji Posts: 3Questions: 1Answers: 0
edited October 2016 in Free community support

I am trying to export only visible columns but export option is exporting all the columns.Here is my code:

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Report</title>
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/jquery.dataTables.min.css" />" />
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/buttons.dataTables.min.css" />" />
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/fixedColumns.dataTables.min.css" />" />
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/responsee.css" />" />
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/reset-min.css" />" />
<link type="text/css" rel="stylesheet"
    href="<c:url value="css/cell_styles.css" />" />

<script src="<c:url value="js/jquery-1.12.3.js" />"></script>
<script src="<c:url value="js/jquery.dataTables.min.js" />"></script>
<script src="<c:url value="js/dataTables.buttons.min.js" />"></script>
<script src="<c:url value="js/jszip.min.js" />"></script>
<script src="<c:url value="js/pdfmake.min.js" />"></script>
<script src="<c:url value="js/vfs_fonts.js" />"></script>
<script src="<c:url value="js/buttons.html5.min.js" />"></script>
<script src="<c:url value="js/buttons.colVis.min.js" />"></script>

<script src="<c:url value="js/jquery-ui.min.js" />"></script>
<script src="<c:url value="js/responsee.js" />"></script>
<script src="<c:url value="js/modernizr.js" />"></script>

<script type="text/javascript">

$(document).ready(function() {
    
    //datatable
    var table = $('#reportTable').DataTable( {
         dom: 'Bfrtip',
         buttons: [
          
             {
                 extend: 'excelHtml5',
                 exportOptions: {
                     columns: ':visible'
                 }
             },
             'colvis'
         ]
    } );
    
} );

</script>
</head>
<body class="size-1140">
    <c:set var="context" value="${pageContext.request.contextPath}" />
    <!-- TOP NAV WITH LOGO -->
    <header>
        <nav>
            <div class="line">
                <div class="s-12 l-2">
                    <img class="s-5 l-12 center"
                        src="<c:url value="img/asurion-logo.png"/>" />
                </div>
                <div class="top-nav s-12 l-10 right">
                    <p class="nav-text">Custom menu text</p>
                    <ul class="right">
                        <li><a href="${context}/search">Home</a></li>
                        <li><a>Contact</a></li>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
    <form:form action="" method="GET">
        <table style="border: 3px; background: rgb(243, 244, 248);">
            <tr>
                <td>
                    <table id="reportTable" class="display pretty">
                        <thead>
                            <tr>
                                <c:forEach var="head" items="${listHeaders}">
                                    <th>${head}</th>
                                </c:forEach>
                            </tr>
                        </thead>
                        <tbody>
                            <c:if test="${reportType =='SprintPlanningReport'}">
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.primaryWorkitemReference}</td>
                                        <td>${story.primaryWorkitemName}</td>
                                        <td>${story.primaryWorkitemTeamName}</td>
                                        <td>${story.primaryWorkitemStatusName}</td>
                                        <td>${story.primaryWorkitemEpicName}</td>
                                        <td>${story.primaryWorkitemCustom_ClarityPrj}</td>

                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='CycleDaysReport'}">
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.epicReference}</td>
                                        <td>${story.epicName}</td>
                                        <td>${story.cycleTimeDays}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='CycleTimeReport'}">
                                <h1>Cycle Time Report</h1>
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td><a href="${context}/${story.LOERange}"
                                            style="text-decoration: underline;">${story.LOERange}</a></td>
                                        <td>${story.USCount}</td>
                                        <td>${story.avgMinCycleTime}</td>
                                        <td>${story.avgMaxCycleTime}</td>
                                        <td>${story.avgCycleTime}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='ToDoUserStoriesReport'}">
                                <h1>ToDo User Stories Report</h1>
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.versionOneId}</td>
                                        <td>${story.jiraId}</td>
                                        <td>${story.title}</td>
                                        <td>${story.epic}</td>
                                        <td>${story.release}</td>
                                        <td>${story.clarityProject}</td>
                                        <td>${story.skillGroup}</td>
                                        <td>${story.team}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='CompleteStatusUserStories'}">
                                <h1>Complete Status User Stories Report</h1>
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.versionOneId}</td>
                                        <td>${story.jiraId}</td>
                                        <td>${story.title}</td>
                                        <td>${story.epic}</td>
                                        <td>${story.release}</td>
                                        <td>${story.clarityProject}</td>
                                        <td>${story.skillGroup}</td>
                                        <td>${story.team}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='NoROMUserStories'}">
                                <h1>Get No ROM User Stories Report</h1>
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.versionOneId}</td>
                                        <td>${story.jiraId}</td>
                                        <td>${story.title}</td>
                                        <td>${story.epic}</td>
                                        <td>${story.release}</td>
                                        <td>${story.clarityProject}</td>
                                        <td>${story.skillGroup}</td>
                                        <td>${story.team}</td>
                                        <td>${story.rom}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            <c:if test="${reportType =='ReleaseUserStories'}">
                                <h1>Incorrect Release in Sprint US Report</h1>
                                <c:forEach var="story" items="${lists}">
                                    <tr>
                                        <td>${story.versiononeID}</td>
                                        <td>${story.jiraId}</td>
                                        <td>${story.title}</td>
                                        <td>${story.epic}</td>
                                        <td>${story.release}</td>
                                        <td>${story.clarityProject}</td>
                                        <td>${story.skillGroup}</td>
                                        <td>${story.team}</td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                        </tbody>
                    </table>
        </table>
    </form:form>
</body>
</html>

can anyone please help me out on this ?

Answers

  • allanallan Posts: 64,757Questions: 1Answers: 10,717 Site admin

    That looks like it should work to me. Can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • yaddlyyaddly Posts: 5Questions: 3Answers: 0

    Funny thing is I have similar code and it is working fine, perhaps he needs to update his buttons javascript file version too.

  • TanajiTanaji Posts: 3Questions: 1Answers: 0

    When I am removing the js and css used for sidebar styling it's working. The removed js & css are :
    JS:

    > <script src="<c:url value="js/responsee.js" />"></script>
    > <script src="<c:url value="js/modernizr.js" />"></script>
    

    CSS:

    > <link type="text/css" rel="stylesheet"
    >     href="<c:url value="css/responsee.css" />" />
    > <link type="text/css" rel="stylesheet"
    >     href="<c:url value="css/reset-min.css" />" />
    > <link type="text/css" rel="stylesheet"
    >     href="<c:url value="css/cell_styles.css" />" />
    
  • TanajiTanaji Posts: 3Questions: 1Answers: 0

    So what I should do to have that styling and column visibility+ export to excel only visible columns working?

  • allanallan Posts: 64,757Questions: 1Answers: 10,717 Site admin

    We'd really need a link to the page to understand why it isn't working as it is.

    Allan

This discussion has been closed.