ASF Bugzilla – Attachment 35112 Details for
Bug 61275
Excel could not open <file> because some content is unreadable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
struts action for building excel
ExportXLSXReportAction.java (text/plain), 4.85 KB, created by
Carl Buxbaum
on 2017-07-10 18:09:06 UTC
(
hide
)
Description:
struts action for building excel
Filename:
MIME Type:
Creator:
Carl Buxbaum
Created:
2017-07-10 18:09:06 UTC
Size:
4.85 KB
patch
obsolete
>package com.tradestonesoftware.qb.viewer.controller; > >import java.io.OutputStream; >import java.util.ArrayList; >import java.util.List; > >import javax.servlet.http.HttpServletRequest; >import javax.servlet.http.HttpServletResponse; >import javax.servlet.http.HttpSession; > >import org.apache.struts.action.ActionForm; >import org.apache.struts.action.ActionForward; >import org.apache.struts.action.ActionMapping; >import org.apache.struts.action.ActionMessage; >import org.apache.struts.action.ActionMessages; > >import com.tradestonesoftware.cbo.RowSet; >import com.tradestonesoftware.constants.Globals; >import com.tradestonesoftware.constants.HttpSessionConstants; >import com.tradestonesoftware.login.controller.SuperAction; >import com.tradestonesoftware.qb.dao.DBRowSetBackedByResultSet; >import com.tradestonesoftware.qb.query.ISelectQuery; >import com.tradestonesoftware.qb.viewer.helper.ExportXLSXExcelHelper; >import com.tradestonesoftware.qb.viewer.ui.QueryPageViewer; >import com.tradestonesoftware.security.User; >import com.tradestonesoftware.ui.Formatter; >import com.tradestonesoftware.ui.PageLayout; >import com.tradestonesoftware.util.Context; > >/** > * > * @author Jagadish > * @Date 08/31/2011 ExportXLSXReportAction generates .xlsx excel reports > * > */ > >public class ExportXLSXReportAction extends SuperAction >{ > final static String REPORT_ERROR_FWD = "error"; > > public ActionForward process(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) > { > ActionForward actionFwd = null; > ActionMessages actionMessages = new ActionMessages(); > try > { > handleFopPOI(request, response, actionMessages); > > } > catch (Exception e) > { > ActionMessage err = new ActionMessage(Globals.ERROR_MSG, e.getMessage()); > actionMessages.add(ActionMessages.GLOBAL_MESSAGE, err); > saveMessages(request, actionMessages); > if (log.isDebugEnabled()) > { > log.debug("Error in ExportXLSXReportAction.process method.", e); > } > actionFwd = mapping.findForward(REPORT_ERROR_FWD); > } > > return actionFwd; > } > > /** > * > * writes .xlsx excel reports contents to OutputStream > * > * @param request > * @param response > * @throws Exception > */ > > private void handleFopPOI(HttpServletRequest request, HttpServletResponse response,ActionMessages actionMessages) throws Exception > { > try > { > HttpSession session = request.getSession(); > User user = (User) session.getAttribute(HttpSessionConstants.USER); > PageLayout pg = (PageLayout) session.getAttribute(HttpSessionConstants.PAGELAYOUT); > Formatter formatter = (Formatter) session.getAttribute(HttpSessionConstants.FORMATTER); > Context context = (Context)request.getAttribute("XLSX_REPORT_CONTEXT"); > DBRowSetBackedByResultSet dbRowSetBackedRS = (DBRowSetBackedByResultSet)context.getAttribute("DBROWSET_BACKEDBY_RESULTSET"); > RowSet dbRowSet = (RowSet)context.getAttribute("ROWSET"); > ISelectQuery selectQuery = (ISelectQuery)context.getAttribute("SELECTQUERY"); > List layoutFields = (List)context.getAttribute("LAYOUTFIELDS"); > String queryName = (String)context.getAttribute("QUERYNAME"); > response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); > response.setHeader("content-disposition", "attachment; filename=Results.xlsx"); > //Tracker#:27899 FR09 ALLOW USER TO EXPORT CUSTOM VIEW TO EXCEL & PDF > ArrayList<Object[]> displayViewCols = QueryPageViewer.findDisplayViewColumn(dbRowSet.getCols(), user, request) ; > ExportXLSXExcelHelper exportDataToExcelxlsx = new ExportXLSXExcelHelper(dbRowSetBackedRS,dbRowSet,selectQuery,layoutFields,user,formatter,queryName, pg); > boolean excelSuccess = exportDataToExcelxlsx.generateQueryDataToExcelReport(displayViewCols); > > if(excelSuccess) > { > OutputStream out = response.getOutputStream(); > //Tracker#25656 - No need to close the OutputStream as we are creating from the response object > exportDataToExcelxlsx.writeWrokBookToStream(out); > out.flush(); > } > else > { > ActionMessage err = new ActionMessage(Globals.ERROR_MSG); > actionMessages.add(ActionMessages.GLOBAL_MESSAGE, err); > saveMessages(request, actionMessages); > > } > } > catch(Exception e) > { > if (log.isDebugEnabled()) > { > log.debug("Error in handleFopPOI method.", e); > } > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 61275
:
35110
|
35111
| 35112 |
35113
|
35114
|
35121