Copy link to clipboard
Copied
I am generating an Excel file with Java on the back-end and it seems to work just fine in Chrome but for whatever reason it doesn't in FF/IE. I have the very latest of Flash in each browser listed from this site: http://helpx.adobe.com/flash-player/kb/find-version-flash-player.html
I'm sending XML to the server, it is generating the Excel and sending it to the Flash. I'm performing the export by doing the following:
private var _fileRef:FileReference;
private function exportReport(e:MouseEvent😞void
{
_fileRef = new FileReference();
_fileRef.addEventListener(Event.COMPLETE, excelExportCompleteHandler);
_fileRef.download(new URLRequest("exportReport"), "report.xlsx");
function excelExportCompleteHandler(e:Event😞void {
trace('complete');
}
}
There are no error messages from Java/Flash. The browse popup comes up and I save the file the same in IE/FF as I do in Chrome. the trace('complete') is executed every time in every browser but the file only shows up when using Chrome.
I also searched my filesystem and found temporary internet file shortcuts with the name of the file I was trying to download so it's as if it started the download but didn't finish it for some reason. The location of those files is AppData\Roaming\Microsoft\Windows\Recent Items
Copy link to clipboard
Copied
Try adding in the full URL to the URLRequest rather than a relative server path (exportReport -> http://server/path/exportReport). Also check the other events for clues, ProgressEvent, SecurityErrorEvent and of course IOErrorEvent.
Chrome tends to be a version behind here and there on the Flash plugin version. Not all the time but sometimes. It could be something WebKit is auto-resolving. If so you can try another WebKit browser like Safari to verify.
Copy link to clipboard
Copied
Hi sinious, I tried full URL and no change.
I tried all events available for FileReference to no avail, I then looked more carefully at the Event.COMPLETE handler and noticed the following message(it didn't show up in the IO Error handler)
Left hand side is a successful download, right hand side is not.
Looks like it's having trouble with those three attributes showing <exception thrown by getter>. I will continue looking into Error #2038: File I/O Error in the meantime but if anyone has any ideas it would be greatly appreciated. I haven't found anything useful searching on this error for the last hour.
Copy link to clipboard
Copied
Could it be, that your whole process (sending the xml, generating the xslx, downloading the xslx) takes longer than 60 seconds?
If so, look at this list of default KeepAlive Timeouts of various browsers. IE has a default of 60 seconds.(Chrome 300).
Copy link to clipboard
Copied
It could be a timeout or you're simply not sending the data correctly to generate the XLSX (if you're sending data). You need to check the code that's requesting the XLSX be generated to be sure no errors occur the same way you're checking the response for errors. Somewhere in the chain data is not being transmitted.
Something tells me if it was a 60 second delay every time you tried you would have mentioned it though so I don't suspect that. I just suspect some issue sending data to the server and the servers response is invalid (erroring, etc, turning your response invalid from a server side error).
Copy link to clipboard
Copied
Definitely not a timeout, it takes < 5 seconds for the web service call to finish
I can also copy and paste the request url with data into the browser and it will successfully download the report just through the browser which made me realize I could use javascript as a non-ideal workaround solution to this problem.
I would still love to know why it was failing and if anyone has any ideas that would be great but for anyone else with the same issue as me here is the workaround I used:
as3 code (I used URLVariables to encode the data because trying encodeURI or encodeURIComponent didn't encode ' or " which would cause errors when doing the ExternalInterface.call()
var reportData:String = getReportXML().toString();
var variables:URLVariables = new URLVariables();
variables.q = reportData;
//Substring at 2 to trim off the 'q=' portion
reportData = variables.toString().substring(2);
ExternalInterface.call("function() { return downloadExcelReport('"+reportData+"')}");
javascript code (I used a hidden form because I needed to be able to perform a POST because the xml data I was passing was too large for a GET)
<script type="text/javascript">
function downloadExcelReport(reportData) {
reportData = decodeURIComponent(reportData);
window.open("about:blank", "newWindow");
document.getElementById("reportData").value = reportData;
document.getElementById("reportForm").submit();
}
</script>
<form id="reportForm" method="post" target="newWindow" action="<%=SERVER_PATH%>excelReport">
<input type="hidden" name="solutionReportXml" id="reportData" value="">
</form>
Find more inspiration, events, and resources on the new Adobe Community
Explore Now