Problem when i try to download an excel file(Contains Pivot table and charts)- but able to open the file by saving in local disk and open

HI Team,

we are generating a excel file with pivot table and pivot chart through the application. when we try to download the generated excel file by click on open button from File Download prompt.

File which we opened dosnt contain any data in the pivit table and chats. but data is populated only in source sheets.

But the same file while downloding if we save in a local disk and try to open then we are able to see tall the information in the file.i.e file is opened with source sheets, pivot table populated based on the source data and Pivot charts are also generated successfully.

Can you please suggest us how to get the generated file with complete information on click on the open button in the download prompt.

Thankls in Advance.

Hi,

Which version of Aspose.Cells you are using? We recommend you to use latest version v5.1.2

Kindly do post your sample code or sample web form file here, we will check your issue soon.

Thank you.

Hi,

Thank you for your reply,
Can you please send me latest version of Aspose.cells jar for java, so that i can test my code with the latest version and let you know whether the issue is still there with latest version.

The Aspose.cells version which you have given in your previous mail is .Net version.Can you please provide me java version link.
Thanks in Advance.

Hi,

You may download the latest version of Aspose.Cells for Java from here.

Also, I have attached the latest version/fix of the product here with this post.

Thank you.

Hi,

Thank you for sending me the jar file.

I tried with the latest jar which you have sent, but even then i am facing the same problem.

when i generate excel file with pivot table and pivot chart through web application, a popup window will diaplay for the file download.

when i click on Open button in the window, generated xls will been opened with data source sheets, but pivot table sheets are not populated but the when you click on the pivot chart area in the sheet bourder of he pivot table is displayed without data and pivot chart is not been generated.

But for the same excel generation action, when i click on the save button and try to save the file on my local disk and the try to open the saved file in that case is xls file is generated as per the requirement(source data sheets with data, pivot tables with data and pivot chart is also been generated successfully).

I didnt understand why report is not generated properly on click on open button.

Sample code to get byte array of the workbook.

ByteArrayOutputStream stream = new ByteArrayOutputStream();

workbook.save(stream, FileFormatType.EXCEL2003);

byt = stream.toByteArray();

The above byte array is set to the HTTPServletResponse object, Code is as below

response.addHeader("Content-Disposition", "attachment; filename=\""

+ reportBean.getReportType()+".xls" + "\"");

response.setContentType("application/octet-stream");

response.setHeader("Pragma", "public");

response.setHeader("Cache-Control", "must-revalidate");

int totalLength = content.length;

response.setContentLength((int) totalLength);

OutputStream outputStream;

try {

outputStream = response.getOutputStream();

outputStream.write(content);

outputStream.flush();

outputStream.close();

} catch (IOException e) {

throw new DmnRtException("Could not write data to response stream",e);

}

Please have a look on the above code and could you please suggest the solution to over come the above problem.

Thanks in Advance.

Hi,

Could you try to change the line of code to:

response.addHeader(“Content-Disposition”, “inline; filename=”"


+ reportBean.getReportType()+".xls" + “”");

response.setContentType("application/octet-stream");

response.setHeader("Pragma", "public");

response.setHeader("Cache-Control", "must-revalidate");

int totalLength = content.length;

response.setContentLength((int) totalLength);

OutputStream outputStream;


Hi,

Thank u very much,

its working fine, i changed the code as per your above comments.

Thank u

Hi ,

we faced one problem,

response.addHeader("Content-Disposition", "inline; filename=\""+ reportBean.getReportType()+".xls" + "\"");

In the above sample code as we set Content-Disposition as inline, when we try to download the file and try to open the file on the title bar should show the file name, bit its is showing servletpath.

Suppose my url from which i am generating report is `https://localhost:8080/abc/report_search.htm`, when i open the file on the title bar it shows report_search.htm but it should show the name of the file.

Please find the attachment(Screen shot) below.

please help me to resolving the above issue.

Hi,

I think it might be the default behavior / routine of the browser (e.g IE) and nothing to do with Aspose.Cells for Java component.

Thank you.

Hello,

Your previously solution with "Content-Disposition", "inline" worked for us, (though there was a file name related issue)

But we would be no longer be able to use "Content-Disposition", "inline" baecuse, it opens the excel file in the browser itself (in a plugin attached to the browser)
Instead, we want it to be a save/open dialog box. For this we need to move back to "Content-Disposition", "attachment".
Is there any other solution/fix that we can use that will solve our previous problem with Pivot table and charts while using it as attachment ?

Thanks

Hi,

Well, I am afraid there might be no other alternative except “Content-Disposition”, “inline” while opening file (by download dialog box) having pivot tables. See the document for your complete reference:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/pivot-table-issue.html

Thank you.