You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2011/09/26 19:30:26 UTC

IE open excel file directly but not save as

Hello ,

I know its not really struts question. But maybe someone knows the answer.

IE cannot open an excel file directly (IE8,9)

  res.reset();
  res.setHeader("Cache-Control", "private, must-revalidate");
  res.setHeader("Pragma","private");
  res.setContentType("application/vnd.ms-excel");
  res.setHeader("Content-Disposition", "inline;filename=\""+ "fn.xls" + 
"\";");
  res.setContentLength(fileData.length);
  res.setHeader("Content-Transfer-Encoding", "binary");

If I save as a file, open it, excel shows:

  "Office File Validation detected a problem while trying to open this 
file. Opening it may be dangerous"

Then I have to click "open" to open it.

Does someone know how to open excel file directly but not have to save 
as under IE please?

thanks a lot!
Emi

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: IE open excel file directly but not save as

Posted by Chris Pratt <th...@gmail.com>.
Gees, I hope not!!!  I'd hate to go to a site and have my printer start
pumping out paper.  The best you can do is call document.print(); which will
bring up the print dialog, but that should be as close to auto-shooting
printouts as you can get.
  (*Chris*)

On Mon, Sep 26, 2011 at 9:15 PM, Rakeshkumar Parmar <
rakeshkumar_parmar@persistent.co.in> wrote:

> Hi,
>
>  I am facing a similar problem. But instead of just opening a file, I want
> to force print .
>
>  Is this possible using http headers or by any other mechanism ?
>
>  I would really appreciate if there is any solution.
>
> Regards,
> Rakesh
>
>
>
>
> -----Original Message-----
> From: Emi Lu [mailto:emilu@encs.concordia.ca]
> Sent: Tuesday, September 27, 2011 12:34 AM
> To: user@struts.apache.org
> Subject: Re: IE open excel file directly but not save as
>
> All right, after so many testing with diff IE versions, here comes the
> trick:
>
> res.setHeader("Content-Disposition", "attachment;filename=\""+
> "test.xls" + "\";");
>
> inline -> attachment.
>
> Emi
>
>
> On 09/26/2011 02:05 PM, Emi Lu wrote:
> > Hi Chris,
> >
> > thanks a lot!
> >
> > I updated to :
> >
> > res.setHeader("Cache-Control", "private");
> > res.setHeader("Cache-Control", "private, must-revalidate");
> > res.setHeader("Pragma","private");
> > res.setContentType("application/vnd.ms-excel");
> > res.setHeader("Content-Disposition", "inline");
> > res.setContentLength(fileData.length);
> > res.setHeader("Content-Transfer-Encoding", "binary");
> >
> >
> > IE 9 works, but IE8 still did not open the file :(
> >
> > Do you know how to fix the problem for IE8.
> >
> > Emi
> >
> >
> >
> >
> > On 09/26/2011 01:40 PM, Chris Pratt wrote:
> >> Try removing the filename from the Content-Disposition header. "inline"
> >> doesn't support this attribute and maybe IE is assuming you mean
> >> "external" because it's there.
> >> (*Chris*)
> >>
> >> On Mon, Sep 26, 2011 at 10:30 AM, Emi Lu <emilu@encs.concordia.ca
> >> <ma...@encs.concordia.ca>> wrote:
> >>
> >> Hello ,
> >>
> >> I know its not really struts question. But maybe someone knows the
> >> answer.
> >>
> >> IE cannot open an excel file directly (IE8,9)
> >>
> >> res.reset();
> >> res.setHeader("Cache-Control", "private, must-revalidate");
> >> res.setHeader("Pragma","__private");
> >> res.setContentType("__application/vnd.ms-excel");
> >> res.setHeader("Content-__Disposition", "inline;filename=\""+
> >> "fn.xls" + "\";");
> >> res.setContentLength(fileData.__length);
> >> res.setHeader("Content-__Transfer-Encoding", "binary");
> >>
> >> If I save as a file, open it, excel shows:
> >>
> >> "Office File Validation detected a problem while trying to open this
> >> file. Opening it may be dangerous"
> >>
> >> Then I have to click "open" to open it.
> >>
> >> Does someone know how to open excel file directly but not have to
> >> save as under IE please?
> >>
> >> thanks a lot!
> >> Emi
> >>
> >>
> ------------------------------__------------------------------__---------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.__apache.org
> >> <ma...@struts.apache.org>
> >> For additional commands, e-mail: user-help@struts.apache.org
> >> <ma...@struts.apache.org>
> >>
> >>
> >
> >
>
>
> --
> Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
> emilu@encs.concordia.ca        +1 514 848-2424 x5884
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
> DISCLAIMER
> ==========
> This e-mail may contain privileged and confidential information which is
> the property of Persistent Systems Ltd. It is intended only for the use of
> the individual or entity to which it is addressed. If you are not the
> intended recipient, you are not authorized to read, retain, copy, print,
> distribute or use this message. If you have received this communication in
> error, please notify the sender and delete all copies of this message.
> Persistent Systems Ltd. does not accept any liability for virus infected
> mails.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: IE open excel file directly but not save as

Posted by Rakeshkumar Parmar <ra...@persistent.co.in>.
Hi,

 I am facing a similar problem. But instead of just opening a file, I want to force print .

 Is this possible using http headers or by any other mechanism ? 

  I would really appreciate if there is any solution.

Regards,
Rakesh




-----Original Message-----
From: Emi Lu [mailto:emilu@encs.concordia.ca] 
Sent: Tuesday, September 27, 2011 12:34 AM
To: user@struts.apache.org
Subject: Re: IE open excel file directly but not save as

All right, after so many testing with diff IE versions, here comes the 
trick:

res.setHeader("Content-Disposition", "attachment;filename=\""+ 
"test.xls" + "\";");

inline -> attachment.

Emi


On 09/26/2011 02:05 PM, Emi Lu wrote:
> Hi Chris,
>
> thanks a lot!
>
> I updated to :
>
> res.setHeader("Cache-Control", "private");
> res.setHeader("Cache-Control", "private, must-revalidate");
> res.setHeader("Pragma","private");
> res.setContentType("application/vnd.ms-excel");
> res.setHeader("Content-Disposition", "inline");
> res.setContentLength(fileData.length);
> res.setHeader("Content-Transfer-Encoding", "binary");
>
>
> IE 9 works, but IE8 still did not open the file :(
>
> Do you know how to fix the problem for IE8.
>
> Emi
>
>
>
>
> On 09/26/2011 01:40 PM, Chris Pratt wrote:
>> Try removing the filename from the Content-Disposition header. "inline"
>> doesn't support this attribute and maybe IE is assuming you mean
>> "external" because it's there.
>> (*Chris*)
>>
>> On Mon, Sep 26, 2011 at 10:30 AM, Emi Lu <emilu@encs.concordia.ca
>> <ma...@encs.concordia.ca>> wrote:
>>
>> Hello ,
>>
>> I know its not really struts question. But maybe someone knows the
>> answer.
>>
>> IE cannot open an excel file directly (IE8,9)
>>
>> res.reset();
>> res.setHeader("Cache-Control", "private, must-revalidate");
>> res.setHeader("Pragma","__private");
>> res.setContentType("__application/vnd.ms-excel");
>> res.setHeader("Content-__Disposition", "inline;filename=\""+
>> "fn.xls" + "\";");
>> res.setContentLength(fileData.__length);
>> res.setHeader("Content-__Transfer-Encoding", "binary");
>>
>> If I save as a file, open it, excel shows:
>>
>> "Office File Validation detected a problem while trying to open this
>> file. Opening it may be dangerous"
>>
>> Then I have to click "open" to open it.
>>
>> Does someone know how to open excel file directly but not have to
>> save as under IE please?
>>
>> thanks a lot!
>> Emi
>>
>> ------------------------------__------------------------------__---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.__apache.org
>> <ma...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>> <ma...@struts.apache.org>
>>
>>
>
>


-- 
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: IE open excel file directly but not save as

Posted by Emi Lu <em...@encs.concordia.ca>.
All right, after so many testing with diff IE versions, here comes the 
trick:

res.setHeader("Content-Disposition", "attachment;filename=\""+ 
"test.xls" + "\";");

inline -> attachment.

Emi


On 09/26/2011 02:05 PM, Emi Lu wrote:
> Hi Chris,
>
> thanks a lot!
>
> I updated to :
>
> res.setHeader("Cache-Control", "private");
> res.setHeader("Cache-Control", "private, must-revalidate");
> res.setHeader("Pragma","private");
> res.setContentType("application/vnd.ms-excel");
> res.setHeader("Content-Disposition", "inline");
> res.setContentLength(fileData.length);
> res.setHeader("Content-Transfer-Encoding", "binary");
>
>
> IE 9 works, but IE8 still did not open the file :(
>
> Do you know how to fix the problem for IE8.
>
> Emi
>
>
>
>
> On 09/26/2011 01:40 PM, Chris Pratt wrote:
>> Try removing the filename from the Content-Disposition header. "inline"
>> doesn't support this attribute and maybe IE is assuming you mean
>> "external" because it's there.
>> (*Chris*)
>>
>> On Mon, Sep 26, 2011 at 10:30 AM, Emi Lu <emilu@encs.concordia.ca
>> <ma...@encs.concordia.ca>> wrote:
>>
>> Hello ,
>>
>> I know its not really struts question. But maybe someone knows the
>> answer.
>>
>> IE cannot open an excel file directly (IE8,9)
>>
>> res.reset();
>> res.setHeader("Cache-Control", "private, must-revalidate");
>> res.setHeader("Pragma","__private");
>> res.setContentType("__application/vnd.ms-excel");
>> res.setHeader("Content-__Disposition", "inline;filename=\""+
>> "fn.xls" + "\";");
>> res.setContentLength(fileData.__length);
>> res.setHeader("Content-__Transfer-Encoding", "binary");
>>
>> If I save as a file, open it, excel shows:
>>
>> "Office File Validation detected a problem while trying to open this
>> file. Opening it may be dangerous"
>>
>> Then I have to click "open" to open it.
>>
>> Does someone know how to open excel file directly but not have to
>> save as under IE please?
>>
>> thanks a lot!
>> Emi
>>
>> ------------------------------__------------------------------__---------
>> To unsubscribe, e-mail: user-unsubscribe@struts.__apache.org
>> <ma...@struts.apache.org>
>> For additional commands, e-mail: user-help@struts.apache.org
>> <ma...@struts.apache.org>
>>
>>
>
>


-- 
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: IE open excel file directly but not save as

Posted by Emi Lu <em...@encs.concordia.ca>.
Hi Chris,

thanks a lot!

I updated to :

  res.setHeader("Cache-Control", "private");
  res.setHeader("Cache-Control", "private, must-revalidate");
  res.setHeader("Pragma","private");
  res.setContentType("application/vnd.ms-excel");
   res.setHeader("Content-Disposition", "inline");
   res.setContentLength(fileData.length);
   res.setHeader("Content-Transfer-Encoding", "binary");


IE 9 works, but IE8 still did not open the file :(

Do you know how to fix the problem for IE8.

Emi




On 09/26/2011 01:40 PM, Chris Pratt wrote:
> Try removing the filename from the Content-Disposition header. "inline"
> doesn't support this attribute and maybe IE is assuming you mean
> "external" because it's there.
>    (*Chris*)
>
> On Mon, Sep 26, 2011 at 10:30 AM, Emi Lu <emilu@encs.concordia.ca
> <ma...@encs.concordia.ca>> wrote:
>
>     Hello ,
>
>     I know its not really struts question. But maybe someone knows the
>     answer.
>
>     IE cannot open an excel file directly (IE8,9)
>
>       res.reset();
>       res.setHeader("Cache-Control", "private, must-revalidate");
>       res.setHeader("Pragma","__private");
>       res.setContentType("__application/vnd.ms-excel");
>       res.setHeader("Content-__Disposition", "inline;filename=\""+
>     "fn.xls" + "\";");
>       res.setContentLength(fileData.__length);
>       res.setHeader("Content-__Transfer-Encoding", "binary");
>
>     If I save as a file, open it, excel shows:
>
>     "Office File Validation detected a problem while trying to open this
>     file. Opening it may be dangerous"
>
>     Then I have to click "open" to open it.
>
>     Does someone know how to open excel file directly but not have to
>     save as under IE please?
>
>     thanks a lot!
>     Emi
>
>     ------------------------------__------------------------------__---------
>     To unsubscribe, e-mail: user-unsubscribe@struts.__apache.org
>     <ma...@struts.apache.org>
>     For additional commands, e-mail: user-help@struts.apache.org
>     <ma...@struts.apache.org>
>
>


-- 
Emi Lu, ENCS, Concordia University, Montreal H3G 1M8
emilu@encs.concordia.ca        +1 514 848-2424 x5884

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: IE open excel file directly but not save as

Posted by Chris Pratt <th...@gmail.com>.
Try removing the filename from the Content-Disposition header.  "inline"
doesn't support this attribute and maybe IE is assuming you mean "external"
because it's there.
  (*Chris*)

On Mon, Sep 26, 2011 at 10:30 AM, Emi Lu <em...@encs.concordia.ca> wrote:

> Hello ,
>
> I know its not really struts question. But maybe someone knows the answer.
>
> IE cannot open an excel file directly (IE8,9)
>
>  res.reset();
>  res.setHeader("Cache-Control", "private, must-revalidate");
>  res.setHeader("Pragma","**private");
>  res.setContentType("**application/vnd.ms-excel");
>  res.setHeader("Content-**Disposition", "inline;filename=\""+ "fn.xls" +
> "\";");
>  res.setContentLength(fileData.**length);
>  res.setHeader("Content-**Transfer-Encoding", "binary");
>
> If I save as a file, open it, excel shows:
>
>  "Office File Validation detected a problem while trying to open this file.
> Opening it may be dangerous"
>
> Then I have to click "open" to open it.
>
> Does someone know how to open excel file directly but not have to save as
> under IE please?
>
> thanks a lot!
> Emi
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: user-unsubscribe@struts.**apache.org<us...@struts.apache.org>
> For additional commands, e-mail: user-help@struts.apache.org
>
>