0

I have an export to excel link which when clicked Javascript calls action class.

JS looks like this:

function exportFt()
{
    alert("Export Ft");
    var url = "<c:out value='${model.contextPath}'/>/CaseIdsExport.do?";
    document.forms[0].action=url;
    document.forms[0].submit();
}

Struts-config looks like this:

    type="com.avt.CaseExportToExcelAction"
          name="CaseExportToExcelForm" 
          parameter="operation">
  </action>

CaseExportToExcelAction open the excel and displays report. But what happens is my browsers itself opens excel. But i want my browser to stay and excel open up seperately. How do i do that?

Geek
  • 3,187
  • 15
  • 70
  • 115

1 Answers1

1

try add this in your action / servlet:

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename="
                        +  manager.getReportName() + ".xlsx");
Vargan
  • 1,277
  • 1
  • 11
  • 35