<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PEAR and CakePHP</title>
	<atom:link href="http://www.hirdweb.com/2009/05/04/pear-and-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/</link>
	<description>Another Blog clogging up the already crowded internet</description>
	<lastBuildDate>Fri, 30 Jul 2010 07:06:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: cartosys</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-248</link>
		<dc:creator>cartosys</dc:creator>
		<pubDate>Wed, 07 Jul 2010 16:21:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-248</guid>
		<description>per francis&#039;s problem: Hi, Im trying to make this work.. Im getting an error which says, “Warning (2): require_once(Console/Getopt.php) [function.require-once]: failed to open stream: No such file or directory [CORE/vendors/Pear/System.php, line 21]“

My solution was to comment out line 21 in System.php.  I did the &quot;modify the core files&quot; nono, but don&#039;t know what other solution to take...</description>
		<content:encoded><![CDATA[<p>per francis&#8217;s problem: Hi, Im trying to make this work.. Im getting an error which says, “Warning (2): require_once(Console/Getopt.php) [function.require-once]: failed to open stream: No such file or directory [CORE/vendors/Pear/System.php, line 21]“</p>
<p>My solution was to comment out line 21 in System.php.  I did the &#8220;modify the core files&#8221; nono, but don&#8217;t know what other solution to take&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francis</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-233</link>
		<dc:creator>Francis</dc:creator>
		<pubDate>Mon, 18 Jan 2010 07:27:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-233</guid>
		<description>saw what the problem is.. no problem with your steps.. it had an issue with something that i set to my view in my beforeFilter function.</description>
		<content:encoded><![CDATA[<p>saw what the problem is.. no problem with your steps.. it had an issue with something that i set to my view in my beforeFilter function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-232</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Mon, 18 Jan 2010 02:23:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-232</guid>
		<description>All the steps I did are listed out here. I modified one step, but I called that out in the post, and highlighted it. When I get a spreadsheet full of special characters, that usually means that there was an error somewhere in the code that I needed to go back and correct.</description>
		<content:encoded><![CDATA[<p>All the steps I did are listed out here. I modified one step, but I called that out in the post, and highlighted it. When I get a spreadsheet full of special characters, that usually means that there was an error somewhere in the code that I needed to go back and correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francis</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-231</link>
		<dc:creator>Francis</dc:creator>
		<pubDate>Mon, 18 Jan 2010 01:55:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-231</guid>
		<description>i just followed what you did here.. are there any extra steps to be done?</description>
		<content:encoded><![CDATA[<p>i just followed what you did here.. are there any extra steps to be done?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-230</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Fri, 15 Jan 2010 14:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-230</guid>
		<description>With the special characters, what are you trying to output, and are you sure that you are sending the data out in UTF-8? Microsoft Excel usually tries to do what it thinks is best, which is most of the time wrong. So make sure the encoding is correct. 

Also, if there is an error in the logic before it outputs, like calling a variable that is not there, it could send out an error, and send special characters.</description>
		<content:encoded><![CDATA[<p>With the special characters, what are you trying to output, and are you sure that you are sending the data out in UTF-8? Microsoft Excel usually tries to do what it thinks is best, which is most of the time wrong. So make sure the encoding is correct. </p>
<p>Also, if there is an error in the logic before it outputs, like calling a variable that is not there, it could send out an error, and send special characters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francis</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-229</link>
		<dc:creator>Francis</dc:creator>
		<pubDate>Fri, 15 Jan 2010 09:26:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-229</guid>
		<description>Hi, its me again.. I was able to make it work.. it generates the excel file but then the contents of the worksheet isnt right.. its full of special characters.. 

help please?</description>
		<content:encoded><![CDATA[<p>Hi, its me again.. I was able to make it work.. it generates the excel file but then the contents of the worksheet isnt right.. its full of special characters.. </p>
<p>help please?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francis</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-228</link>
		<dc:creator>Francis</dc:creator>
		<pubDate>Fri, 15 Jan 2010 08:54:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-228</guid>
		<description>Hi, Im trying to make this work.. Im getting an error which says, &quot;Warning (2): require_once(Console/Getopt.php) [function.require-once]: failed to open stream: No such file or directory [CORE/vendors/Pear/System.php, line 21]&quot;</description>
		<content:encoded><![CDATA[<p>Hi, Im trying to make this work.. Im getting an error which says, &#8220;Warning (2): require_once(Console/Getopt.php) [function.require-once]: failed to open stream: No such file or directory [CORE/vendors/Pear/System.php, line 21]&#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-145</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Mon, 25 May 2009 12:25:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-145</guid>
		<description>Chris, I like the approach. You are correct in that in a true MVC approach, it should be in the view. Since my approach was just for 1 report, it clogs the controller only a little, but I still ought to change this around according to your suggestion. 

Maybe, to be even cleaner in the view, we could take the Excel object, put it in a helper, with certain functions, so that the excel writer will have its code in a central place and called in various views to build different excel reports.

Great suggestion Chris.</description>
		<content:encoded><![CDATA[<p>Chris, I like the approach. You are correct in that in a true MVC approach, it should be in the view. Since my approach was just for 1 report, it clogs the controller only a little, but I still ought to change this around according to your suggestion. </p>
<p>Maybe, to be even cleaner in the view, we could take the Excel object, put it in a helper, with certain functions, so that the excel writer will have its code in a central place and called in various views to build different excel reports.</p>
<p>Great suggestion Chris.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-144</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Sun, 24 May 2009 20:18:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-144</guid>
		<description>Hi again Stephen... figured I&#039;d update you on this since I found your post so helpful.

I&#039;ve been working with this and found what I believe is a more &quot;cake like&quot; or more &quot;true&quot; MVC method of rendering the view for the excel spreadsheet. I am building a reporting system for my app and I soon found my &quot;reports&quot; controller was getting really full of many functions to create the various spreadsheets. I figured that really the spreadsheet exports are actually views so the code for constructing them should be in a view file. 

This is what I&#039;ve done: 

1) Copied the empty ajax.ctp layout from ./cake/libs/view/layouts/ into ./app/views/layouts/ and renamed it excel.ctp.

2) Used $this-&gt;layout and $this-&gt;render in the controller to send requests for reports (i.e. the excel spreadsheets) to a specific view file using the &quot;excel&quot; layout. For example:

// either export to excel or show the normal view
if ($export != &#039;export&#039;) {
	$this-&gt;render(&#039;report_name&#039;);
} else {
	$this-&gt;layout = &#039;excel&#039;;
	$this-&gt;render(&#039;report_name_export&#039;);
}

In my case I have the &quot;report_name.ctp&quot; view which shows the report on screen normally and the &quot;report_name_export.ctp&quot; view which exports the report to excel using the method you described.

Each &quot;export&quot; view must include the line to import the Spreadsheet_Excel_Writer library:

App::import(&#039;vendor&#039;, &#039;Spreadsheet_Excel_Writer&#039;, array(&#039;file&#039; =&gt; &#039;../vendors/Pear/Spreadsheet/Excel/Writer.php&#039;

(I tried to put this in the excel.ctp layout but it didn&#039;t seem to work, no idea why)

This makes it much cleaner IMO and for me at least it&#039;s much easier to work with every export in the individual view file rather than clogging up my controller!

Best wishes
Chris</description>
		<content:encoded><![CDATA[<p>Hi again Stephen&#8230; figured I&#8217;d update you on this since I found your post so helpful.</p>
<p>I&#8217;ve been working with this and found what I believe is a more &#8220;cake like&#8221; or more &#8220;true&#8221; MVC method of rendering the view for the excel spreadsheet. I am building a reporting system for my app and I soon found my &#8220;reports&#8221; controller was getting really full of many functions to create the various spreadsheets. I figured that really the spreadsheet exports are actually views so the code for constructing them should be in a view file. </p>
<p>This is what I&#8217;ve done: </p>
<p>1) Copied the empty ajax.ctp layout from ./cake/libs/view/layouts/ into ./app/views/layouts/ and renamed it excel.ctp.</p>
<p>2) Used $this-&gt;layout and $this-&gt;render in the controller to send requests for reports (i.e. the excel spreadsheets) to a specific view file using the &#8220;excel&#8221; layout. For example:</p>
<p>// either export to excel or show the normal view<br />
if ($export != &#8216;export&#8217;) {<br />
	$this-&gt;render(&#8216;report_name&#8217;);<br />
} else {<br />
	$this-&gt;layout = &#8216;excel&#8217;;<br />
	$this-&gt;render(&#8216;report_name_export&#8217;);<br />
}</p>
<p>In my case I have the &#8220;report_name.ctp&#8221; view which shows the report on screen normally and the &#8220;report_name_export.ctp&#8221; view which exports the report to excel using the method you described.</p>
<p>Each &#8220;export&#8221; view must include the line to import the Spreadsheet_Excel_Writer library:</p>
<p>App::import(&#8216;vendor&#8217;, &#8216;Spreadsheet_Excel_Writer&#8217;, array(&#8216;file&#8217; =&gt; &#8216;../vendors/Pear/Spreadsheet/Excel/Writer.php&#8217;</p>
<p>(I tried to put this in the excel.ctp layout but it didn&#8217;t seem to work, no idea why)</p>
<p>This makes it much cleaner IMO and for me at least it&#8217;s much easier to work with every export in the individual view file rather than clogging up my controller!</p>
<p>Best wishes<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://www.hirdweb.com/2009/05/04/pear-and-cakephp/comment-page-1/#comment-137</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Thu, 07 May 2009 03:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.hirdweb.com/?p=185#comment-137</guid>
		<description>I have updated the post with the include_path information so that there is no need to edit the PEAR library files.</description>
		<content:encoded><![CDATA[<p>I have updated the post with the include_path information so that there is no need to edit the PEAR library files.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
