<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Proc Export Error: Excel cannot open the file. in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393711#M5516</link>
    <description>&lt;P&gt;What SAS version are you using? XLSX only became available in 9.4M2. Try XLS also.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 20:49:38 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2017-09-06T20:49:38Z</dc:date>
    <item>
      <title>Proc Export Error: Excel cannot open the file.</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393691#M5515</link>
      <description>&lt;P&gt;I am trying to create excel spreadsheet via the stored process by using Proc Export. Log suggests that file has been created without any error but when I try to open the file I get this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Excel cannot open the file '&lt;/STRONG&gt;myfile&lt;STRONG&gt;.xlsx' because the file format or the file extension is not valid. Verify that the file has not been corrupted or that the file extension matches the format of the file.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using following code in my stored process to create spreadsheets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%if &amp;amp;Output=EXCEL %then %do;
data _null_;
   rc=stpsrv_header('Content-type','application/vnd.ms-excel');
   rc=stpsrv_header('Content-disposition',"attachment; filename=&amp;amp;geosumlvl._&amp;amp;tabname..xlsx");         
run;

proc export data=Extract_ACS outfile=_webout dbms=xlsx replace;
sheet='mysheet';
run;

%end;&lt;/PRE&gt;
&lt;P&gt;I am wondering if we have a solution to resolve this issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 19:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393691#M5515</guid>
      <dc:creator>mrg1212005</dc:creator>
      <dc:date>2017-09-06T19:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export Error: Excel cannot open the file.</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393711#M5516</link>
      <description>&lt;P&gt;What SAS version are you using? XLSX only became available in 9.4M2. Try XLS also.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 20:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393711#M5516</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-09-06T20:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export Error: Excel cannot open the file.</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393714#M5517</link>
      <description>&lt;P&gt;Is your Excel 32-bit or 64-bit? The 32-bit versions don't like opening 64-bit files.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 21:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/393714#M5517</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-06T21:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export Error: Excel cannot open the file.</title>
      <link>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/394204#M5518</link>
      <description>&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;I don't think that PROC EXPORT correctly writes to the _WEBOUT FIILEREF, even though no errors are reported.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Try this code and if it works, then you can adapt it to your data:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_ close;

data _null_;
rc=stpsrv_header('Content-type','application/vnd.ms-excel');
rc=stpsrv_header('Content-disposition',"attachment; filename=Class.xlsx");         
run;

%let WORKPATH=%sysfunc(pathname(work));

filename temp "&amp;amp;WORKPATH/temp.xlsx";

proc export data=sashelp.class 
  outfile=temp 
  dbms=xlsx 
  replace;
  sheet='mysheet';
run; quit;

data _null_;
infile temp recfm=f lrecl=1;
file _webout recfm=n;
input;
put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;Vince DelGobbo&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="verdana,geneva"&gt;SAS R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 13:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Proc-Export-Error-Excel-cannot-open-the-file/m-p/394204#M5518</guid>
      <dc:creator>Vince_SAS</dc:creator>
      <dc:date>2017-09-08T13:41:08Z</dc:date>
    </item>
  </channel>
</rss>

