I want to export a jsp table of search results to an MS-Excel '.xlsx' format file

(Edited) Okay let me explain this a little better. I have search page which looks for employees based different search criterion. Now(Due to a scope creep that happened in the QA stage) I want to add an export button which will save the filtered list of employees in a MS-Excel form. I have been looking into Birt report design but I don think thats what I am looking for because its trying to build an independent report. I just want what is being displayed in the JSP page table to be saved as excel.

 <div id="searchResultsContents">
        <p>Search Results:</p>
                <display:table class="cspTable"name="searchEmployees" sort="list"
                    pagesize="10" requestURI="employeeSearch.html" cellspacing="0" cellpadding="0"
                    defaultsort="1" defaultorder="ascending">
                    <display:column property="fullName" title="Name" class="namesColumn"
                        sortable="true" href="showUser.html" paramId="employeeId"
                        paramProperty="employeeID" />
                    <display:column property="occupationalTitle.titleName" title="Title"
                        sortable="true" />
                    <display:column property="email" title="Email"
                        sortable="true" />
                    <display:column property="cycle.cycleName" title="Cycle" 
                        sortable="true" />
                    <display:column property="realLocation.code" title="Location"
                        sortable="true" />
                    <display:column property="hireDate" title="Hire Date"
                        sortable="true" />
                </display:table>
            </div>
        </div>

Thank you

Answers


Excel "knows" how to open HTML/CSV files, so you can do the following:

  1. on the JSP's header add these lines: response.setHeader("Content-disposition:", "attachment; filename='excelfilename.xls';"); response.setHeader("Authorization", request.getHeader("Authorization")); response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8");

  2. make sure the output table is either in CSV or in HTML "table" format


Are you using the DisplayTag library? They incorporate an Export Filter ( http://www.displaytag.org/10/export_filter.html ) that can be used with minimal configuration.


Need Your Help

how can I use font style for my whole frames or dialogs?

java swing

I have a main frame which has a menu bar and let user to change the font of all the texts in my program.I can just set the font for the main frame but how can i set that change for all my frames and

Cannot bulk upload triples to virtuoso graph using the bulk upload functions

transactions rdf graph-databases virtuoso bulk-load

I am trying to upload triples to Virtuoso with the bulk upload function(s) mentioned here: https://github.com/dbpedia/dbpedia-docs/wiki/Loading-Data-Virtuoso. Sometimes the bulk upload is working,