<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Problem with Excel Reports]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=5487</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5487&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Problem with Excel Reports.]]></description>
		<lastBuildDate>Fri, 23 Jan 2015 11:23:42 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22304#p22304</link>
			<description><![CDATA[<p>Just choose a define(&#039;XXXX&#039;,&#039;yyyy&#039;) in the calling script or one that already exists in FA and exit in the called script if it does not exist.</p><p>Sharing it in the public domain will help get rid of such vulnerabilities rather than live with &quot;security thru obscurity&quot;.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Fri, 23 Jan 2015 11:23:42 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22304#p22304</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22303#p22303</link>
			<description><![CDATA[<p>Hi apmuthu, that was the reason of my hesitation to share publicly the mod <img src="https://frontaccounting.com/punbb/img/smilies/smile.png" width="15" height="15" alt="smile" /><br />Although there is a check for legal characters and one has to know the filename in order to be able to download it.<br />But obviously, I have to work more on that issue and will be updating the file to include more security.</p><p>carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Fri, 23 Jan 2015 10:45:37 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22303#p22303</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22302#p22302</link>
			<description><![CDATA[<p>Thanks @carmelr: way to go! Now look at the security implications of anyone having a go at the excel file maker script xlssend.php! Have a check for something to indicate that the user is logged in.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Fri, 23 Jan 2015 10:00:22 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22302#p22302</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22299#p22299</link>
			<description><![CDATA[<p>Here is what I did:</p><p>I created a file in fa/reporting called xlssend.php containing the following code:</p><div class="codebox"><pre><code>&lt;?php
$filename = htmlspecialchars($_GET[&#039;fn&#039;]);
$unique = htmlspecialchars($_GET[&#039;un&#039;]);
    header(&quot;Content-type: application/vnd.ms-excel&quot;);
    header(&quot;Content-Disposition: attachment; filename=&#039;$filename&#039;&quot; );
    header(&quot;Expires: 0&quot;);
    header(&quot;Cache-Control: must-revalidate, post-check=0,pre-check=0&quot;);
    header(&quot;Pragma: public&quot;);
    echo file_get_contents($unique);
?&gt;</code></pre></div><p>Then I modified the file FA/reporting/prn_redirect.php as follows:<br /></p><div class="codebox"><pre><code>if (isset($_GET[&#039;xls&#039;]))
{   
    $filename = $_GET[&#039;filename&#039;];
    $unique_name = preg_replace(&#039;/[^0-9a-z.]/i&#039;, &#039;&#039;, $_GET[&#039;unique&#039;]);
    $path =  company_path(). &#039;/pdf_files/&#039;;
//      header(&quot;Content-type: application/vnd.ms-excel&quot;);
//    header(&quot;Content-Disposition: attachment; filename=&#039;$filename&#039;&quot; );
//    header(&quot;Expires: 0&quot;);
//    header(&quot;Cache-Control: must-revalidate, post-check=0,pre-check=0&quot;);
//    header(&quot;Pragma: public&quot;);
//     echo file_get_contents($path.$unique_name);

    header(&quot;Location: xlssend.php?fn=$filename&amp;un=$path$unique_name&quot;); /* Redirect browser */ 
    exit();
}
elseif (isset($_GET[&#039;xml&#039;]))</code></pre></div><p>That&#039;s it. <br />Hope this will be useful for others.</p><p>Carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Fri, 23 Jan 2015 08:15:35 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22299#p22299</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22290#p22290</link>
			<description><![CDATA[<p>I too am unable to duplicate this error in a test environment in Debian Squeeze, Debian Wheezy and XAMPP v1.7.3 in WinXP SP3 / Win7 / LXDE on Debian 7 Desktop and IE 8 and FF33.</p><p>@carmelr can post the code and location of file include here and/or in the wiki for anyone encountering this problem.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Fri, 23 Jan 2015 05:58:56 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22290#p22290</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22284#p22284</link>
			<description><![CDATA[<p>Thanks Joe.<br />My fix is simply moving out that part of the file that downloads the .xls file. <br />According to my research there is something that is generating the spaces and for some reason they remain in the buffer.</p><p>Moving it out was the only way to get rid of them.</p><p>Carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 21:31:29 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22284#p22284</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22283#p22283</link>
			<description><![CDATA[<p>Ok, carmelr,</p><p>I made a test here in my Environment and I got NO 4 spaces (0x20) in front of the file.</p><p>But if any other have the same problems as Carmelr, please Contact him.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Thu, 22 Jan 2015 21:13:11 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22283#p22283</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22282#p22282</link>
			<description><![CDATA[<p>P R O B L E M&nbsp; &nbsp;S O L V E D</p><p>I created another file that handles just the download of the excel file and passed the necessary parameters to it.</p><p>Now file downloads as it should and opens into Excel without a hitch.</p><p>I can share the code with anyone who is having similar problems.</p><p>Carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 21:02:00 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22282#p22282</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22280#p22280</link>
			<description><![CDATA[<div class="quotebox"><cite>apmuthu wrote:</cite><blockquote><p>Replace the line with:<br /></p><div class="codebox"><pre><code>$abc = &quot;Content-Disposition: attachment; filename=&#039;$filename&#039;&quot;;
header($abc);</code></pre></div></blockquote></div><p>Same results <img src="https://frontaccounting.com/punbb/img/smilies/sad.png" width="15" height="15" alt="sad" /></p><p>I have done more tests as follows:</p><p>I inserted an echo &#039;Testing&#039;; right after <br />If (isset(G_GET[&#039;xls&#039;]))<br />{</p><p>and tried again a report.<br />Now the file contains 4 spaces and Testing.<br />Then I added the following commands after the echo line and or before the first header line:</p><p>flush();<br />ob_clean();<br />ob_end_clean();</p><p>For all of the above, only the four spaces are prepended to the file.</p><p>I believe that somehow, these four spaces are being sent to the browser from a different part of the code and the flush or the ob_clean is not clearing these spaces from the buffers.</p><p>I come to this conclusion because the spaces were added even before the word &#039;Testing&#039; sent before the filename was created.</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 19:33:24 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22280#p22280</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22279#p22279</link>
			<description><![CDATA[<p>Replace the line with:<br /></p><div class="codebox"><pre><code>$abc = &quot;Content-Disposition: attachment; filename=&#039;$filename&#039;&quot;;
header($abc);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 22 Jan 2015 19:09:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22279#p22279</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22278#p22278</link>
			<description><![CDATA[<p>Tried the quotes. Exactly the same results.</p><p><img src="https://frontaccounting.com/punbb/img/smilies/sad.png" width="15" height="15" alt="sad" /></p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 18:27:15 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22278#p22278</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22277#p22277</link>
			<description><![CDATA[<p>See my post of 4 seconds earlier than yours.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 22 Jan 2015 18:23:38 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22277#p22277</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22276#p22276</link>
			<description><![CDATA[<div class="quotebox"><cite>apmuthu wrote:</cite><blockquote><p>This is a browser encoding issue. Try to set the browser encoding to Western and then to Unicode and see the difference. Also what platforms and browsers have you tried? What about a browser in Linux? The major ones - IE 8, FF24+, Chrome (I haven&#039;t tesed it), etc should have their own quirks for encoding settings. Also see if there are any line endings that may be dos instead of unix style in the scripts.</p><p>Also try to upload a good xls file to the server and download it back to see if there are any differences.</p></blockquote></div><p>Thanks apmuthu. I know that the file generated by FA on the Ubuntu server is good as when I downloaded it to my PC using Filezilla the file opened in Excel.<br />Also, when I created the few lines of php code in a separate file to download the file generated by FA through my browser, the file opened in Excel. <br />Then when I changed the code in FA to use the readfile function (like in the php file I created) the spaces appeared again.</p><p>For this reason I don&#039;t think that it is a browser problem or an encoding problem. I do think, though, that FA is setting something internally and is causing the 4 spaces to be prepended to the file.</p><p>Carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 18:20:42 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22276#p22276</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22275#p22275</link>
			<description><![CDATA[<p>The only difference I find is that your $filename is quoted but the one in the code I posted is not!</p><p>Replace line 36 in reporting/prn_redirect.php<br /></p><div class="codebox"><pre><code>    header(&quot;Content-Disposition: attachment; filename=$filename&quot; );</code></pre></div><p>with<br /></p><div class="codebox"><pre><code>    header(&quot;Content-Disposition: attachment; filename=&#039;$filename&#039;&quot;);</code></pre></div><p>Or try swapping the single and double quotes in the replacement as well.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Thu, 22 Jan 2015 18:20:38 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22275#p22275</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem with Excel Reports]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=22273#p22273</link>
			<description><![CDATA[<p>Here&#039;s an update ....</p><p>So I created the following file on the server:<br /></p><div class="codebox"><pre><code>&lt;?php
    header(&#039;Content-type: application/vnd.ms-excel&#039;);
    header(&#039;Content-Disposition: attachment; filename=&quot;test.xls&quot;&#039;);
    readfile(&#039;pdf_files/test.xls&#039;);
?&gt;</code></pre></div><p>called the file and it works. It sends the file and opens in Excel</p><p>So I changed prn_redirect.php to be like the above and the spaces where still being added at the beginning of the file.<br />This means that there is some setting within FA that is causing this.</p><p>I did a lot of research online trying to find what is causing this problem, but I cannot find a solution.<br />Any assistance would be greatly appreciated.</p><p>TIA<br />Carmelo</p>]]></description>
			<author><![CDATA[null@example.com (carmelr)]]></author>
			<pubDate>Thu, 22 Jan 2015 18:07:06 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=22273#p22273</guid>
		</item>
	</channel>
</rss>
