Dialog box to "Open" or "Save"

Hi,
I am currently using jxl for exporting report information to an excel spreadsheet.
My users are used to having a dialog box open then they click my “export” button which says “Do you want to open or save FileName.xls from webSite.edu?” and the buttons to “Open” or “Save”.
Most of the users just click “Open” and excel opens it for them automatically.

How do I replicate that feature? When I tried the sample code, it just created and saved the file without any dialog box, or the option to immediately open the file.

Thanks,
Brita

Hi,


In a web application, you may try the following sample code in a JSP program to sends the file to HttpServletResponse streams.
e.g
Sample code:


Workbook wb = new Workbook();

//…your code goes here.

//Set the content type and add header

String contentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;

response.setContentType(contentType);

response.addHeader(“content-disposition”, “inline;filename=Test.xlsx”);


//Save the workbook in response stream
wb.save(response.getOutputStream(), SaveFormat.XLSX);


Hope, this helps a bit.

Thank you.

Hi Amjad,

This solutions works flawlessly in Firefox, but there is a small problem with IE.

When I tried this with Internet Explorer, a dialog box opened up after I chose to "Open" the file.
First, there is a long pause where the status box at the bottom says " Downloading from site: localhost..."
then a pop-up shows up saying " Downloading: `http://localhost:9082/web/Reports?report=testReport`"
The progress bar stays empty and nothing happens. If I click "Cancel" the box disappears and the spreadsheet opens.
If I wait long enough, sometimes I get a box that says Mocrosoft Excel in the top and "Could not open "`http://localhost:9082/web/Reports?report=testReport`" When I click cancel on that and the next Excel box, the sheet opens up.
Sometimes I get a Windows Security dialog box asking me to "Connect to localhost" and asking for my username and password. When I "x" out of that box, the sheet opens up.

After I go through this once or twice, then it works as it should (except for being kind of slow compared to Firefox). If I close and re-open the browser, I get the same issues again.

I know this post is kind of long, I can get you screenshots if that would be of any help in diagnosing this problem.

Thanks,
Brita

Hi,


Well, I think it is a security issue for your browser type (IE) and nothing to do with Aspose.Cells component. I think you should check/ configure your security settings and assign proper rights to open the sites into it etc. You should browse internet to find out your underlying issue and fix it accordingly by yourself.

Thank you.

Hi Amjad,

We are currently using .jxl for exporting to Excel. It is working fine but for some of our larger reports it is creating very large objects. I have been tasked with finding an alternative method which will result in smaller objects. Which is why I am trying out Aspose. The college is part of a consortium and I don't have any control over the security settings on any of the user's computers. I need the same functionality as I have now, but with smaller objects.

Currently the .jxl export doesn't trigger any alerts or other issues. I have included a document with screen shots that may help.

Is there anything I can possibly do with the code to make it open like it does with .jxl?

Brita

Hi,


Could you replace the line of code i.e.,
response.addHeader(“content-disposition”, “inline;filename=Test.xlsx”);

with::
response.addHeader(“content-disposition”, “attachment;filename=Test.xlsx”);

if it works fine.

Thank you.

Hi Amjad,

Thanks so much! That did the trick.

Brita

Hi,


Good to know that it sorts out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.