<?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"
	>
<channel>
	<title>Comments on: Excel Spreadsheets in PHP using PEAR</title>
	<atom:link href="http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/</link>
	<description>Tips and Tricks for Web Developers</description>
	<pubDate>Wed, 03 Dec 2008 23:00:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: raymanexe</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-100</link>
		<dc:creator>raymanexe</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-100</guid>
		<description>@ Kalyan


Heres a sample code on how to export excel from a database

&#60;?php
/*This require call will be different depending on how your PEAR
 *is installed. The below call works with the zipped test PEAR
 *files I have provided if your script is in the same folder as
 *the zipped PEAR folder.
 *Normally, If you have PEAR installed correctly, you would
 *use the call: require_once('Spreadsheet/Excel/Writer.php'); */
require_once('dbconn.php');
require_once('PEAR/Spreadsheet_Excel_Writer/Writer.php');
 
/* Data to be inserted into excel in an array of arrays
 * Each array is the avg monthly temp of a different city */
$sql = "SELECT * FROM customers";
$result = mysql_query($sql) or die(mysql_error());
$ctr = 0;
$ctr2 = 0;
while($rs = mysql_fetch_assoc($result)):
	for($i = 0; $i send('customers.xls');
 
//Creating a worksheet
$worksheet=&#38;$workbook-&#62;addWorksheet('Export');
$worksheet-&#62;setLandscape();
 
//set all columns same width
$columnWidth = 10;
$worksheet-&#62;setColumn (0, $numColumns, $columnWidth);
 
//Setup different styles
$sheetTitleFormat =&#38; $workbook-&#62;addFormat(array('bold'=&#62;1,
  'size'=&#62;10));
$columnTitleFormat =&#38; $workbook-&#62;addFormat(array('bold'=&#62;1,
  'top'=&#62;1,
  'bottom'=&#62;1 ,
  'size'=&#62;9));
$regularFormat =&#38; $workbook-&#62;addFormat(array('size'=&#62;9,
  'align'=&#62;'left',
  'textWrap'=&#62;1));
 
/*Speadsheet writer is in format y,x (row, column)
 *  column1  &#124;  column2 &#124;  column3
 *   (0,0)      (0,1)      (0,2) */
 
$column = 0;
$row    = 0;
 
//Write sheet title in upper left cell
$worksheet-&#62;write($row, $column, $sheetTitle, $sheetTitleFormat);
 
 
//Write column titles two rows beneath sheet title
$row += 2;
foreach ($columnTitles as $title) {
  $worksheet-&#62;write($row, $column, $title, $columnTitleFormat);
  $column++;
}
 
//Write each datapoint to the sheet starting one row beneath
$row++;
foreach ($data as $subArrayKey =&#62; $subArray) {
  //Loop through each row
  $column = 0;
  foreach ($subArray as $value) {
    //Loop through each row's columns
    $worksheet-&#62;write($row, $column, $value, $regularFormat);
    $column++;
  }
  $row++;
}
$workbook-&#62;close();
?&#62;</description>
		<content:encoded><![CDATA[<p>@ Kalyan</p>
<p>Heres a sample code on how to export excel from a database</p>
<p>&lt;?php<br />
/*This require call will be different depending on how your PEAR<br />
 *is installed. The below call works with the zipped test PEAR<br />
 *files I have provided if your script is in the same folder as<br />
 *the zipped PEAR folder.<br />
 *Normally, If you have PEAR installed correctly, you would<br />
 *use the call: require_once(&#8217;Spreadsheet/Excel/Writer.php&#8217;); */<br />
require_once(&#8217;dbconn.php&#8217;);<br />
require_once(&#8217;PEAR/Spreadsheet_Excel_Writer/Writer.php&#8217;);</p>
<p>/* Data to be inserted into excel in an array of arrays<br />
 * Each array is the avg monthly temp of a different city */<br />
$sql = &#8220;SELECT * FROM customers&#8221;;<br />
$result = mysql_query($sql) or die(mysql_error());<br />
$ctr = 0;<br />
$ctr2 = 0;<br />
while($rs = mysql_fetch_assoc($result)):<br />
	for($i = 0; $i send(&#8217;customers.xls&#8217;);</p>
<p>//Creating a worksheet<br />
$worksheet=&amp;$workbook-&gt;addWorksheet(&#8217;Export&#8217;);<br />
$worksheet-&gt;setLandscape();</p>
<p>//set all columns same width<br />
$columnWidth = 10;<br />
$worksheet-&gt;setColumn (0, $numColumns, $columnWidth);</p>
<p>//Setup different styles<br />
$sheetTitleFormat =&amp; $workbook-&gt;addFormat(array(&#8217;bold&#8217;=&gt;1,<br />
  &#8217;size&#8217;=&gt;10));<br />
$columnTitleFormat =&amp; $workbook-&gt;addFormat(array(&#8217;bold&#8217;=&gt;1,<br />
  &#8216;top&#8217;=&gt;1,<br />
  &#8216;bottom&#8217;=&gt;1 ,<br />
  &#8217;size&#8217;=&gt;9));<br />
$regularFormat =&amp; $workbook-&gt;addFormat(array(&#8217;size&#8217;=&gt;9,<br />
  &#8216;align&#8217;=&gt;&#8217;left&#8217;,<br />
  &#8216;textWrap&#8217;=&gt;1));</p>
<p>/*Speadsheet writer is in format y,x (row, column)<br />
 *  column1  |  column2 |  column3<br />
 *   (0,0)      (0,1)      (0,2) */</p>
<p>$column = 0;<br />
$row    = 0;</p>
<p>//Write sheet title in upper left cell<br />
$worksheet-&gt;write($row, $column, $sheetTitle, $sheetTitleFormat);</p>
<p>//Write column titles two rows beneath sheet title<br />
$row += 2;<br />
foreach ($columnTitles as $title) {<br />
  $worksheet-&gt;write($row, $column, $title, $columnTitleFormat);<br />
  $column++;<br />
}</p>
<p>//Write each datapoint to the sheet starting one row beneath<br />
$row++;<br />
foreach ($data as $subArrayKey =&gt; $subArray) {<br />
  //Loop through each row<br />
  $column = 0;<br />
  foreach ($subArray as $value) {<br />
    //Loop through each row&#8217;s columns<br />
    $worksheet-&gt;write($row, $column, $value, $regularFormat);<br />
    $column++;<br />
  }<br />
  $row++;<br />
}<br />
$workbook-&gt;close();<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raymanexe</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-99</link>
		<dc:creator>raymanexe</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:01:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-99</guid>
		<description>reply on Visi

Hi I encountoured that problem also and managed to fix that. just add this code to your script


$workbook-&#62;setVersion(8);</description>
		<content:encoded><![CDATA[<p>reply on Visi</p>
<p>Hi I encountoured that problem also and managed to fix that. just add this code to your script</p>
<p>$workbook-&gt;setVersion(8);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raymanexe</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-98</link>
		<dc:creator>raymanexe</dc:creator>
		<pubDate>Thu, 27 Nov 2008 00:59:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-98</guid>
		<description>I'm using the code for this export to excel. it works fine in our test server but when i upload to a secure server (https://) it doesn't work. any ideas how to fix this? thanks</description>
		<content:encoded><![CDATA[<p>I&#8217;m using the code for this export to excel. it works fine in our test server but when i upload to a secure server (https://) it doesn&#8217;t work. any ideas how to fix this? thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Visi</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-65</link>
		<dc:creator>Visi</dc:creator>
		<pubDate>Thu, 16 Oct 2008 05:14:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-65</guid>
		<description>Hi,
Really cool solution for creating Excel reports.
I have a issues in writing string of length greater then 255 characters in the cell as it is truncateing the string.
How can I write the string of more than 255 character length. Any solution to this.?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Really cool solution for creating Excel reports.<br />
I have a issues in writing string of length greater then 255 characters in the cell as it is truncateing the string.<br />
How can I write the string of more than 255 character length. Any solution to this.?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yuri</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-58</link>
		<dc:creator>yuri</dc:creator>
		<pubDate>Wed, 08 Oct 2008 21:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-58</guid>
		<description>You saved my life!!!

Thanks, well put together...and you just helped me implement this with AMFPHP with an array comming from a Flex UI.</description>
		<content:encoded><![CDATA[<p>You saved my life!!!</p>
<p>Thanks, well put together&#8230;and you just helped me implement this with AMFPHP with an array comming from a Flex UI.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JNettik</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-48</link>
		<dc:creator>JNettik</dc:creator>
		<pubDate>Fri, 26 Sep 2008 16:13:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-48</guid>
		<description>Nice, exactly what I was looking for.  I can easily adapt this idea to pull data from mySQL and end up with a formatted Excel workbook.  Much better than the csv solution.  My hosted environment has very little PEAR support, so thanks for including the files I needed to get this up and running in minutes.</description>
		<content:encoded><![CDATA[<p>Nice, exactly what I was looking for.  I can easily adapt this idea to pull data from mySQL and end up with a formatted Excel workbook.  Much better than the csv solution.  My hosted environment has very little PEAR support, so thanks for including the files I needed to get this up and running in minutes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalyan</title>
		<link>http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-8</link>
		<dc:creator>Kalyan</dc:creator>
		<pubDate>Mon, 28 Apr 2008 01:34:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.ebrueggeman.com/blog/php/excel-spreadsheets-in-php-using-pear/#comment-8</guid>
		<description>This is really helpful.But i am quering the database and also trying to set up a link so that User can download the Spreadsheeet on their computer. My first problem was how to retrieve my data from the databse and save it in an array. Secondly, i could not use write method as well as landScape method. It will help if you can clear me up on those issues. Thanks!
Kalyan</description>
		<content:encoded><![CDATA[<p>This is really helpful.But i am quering the database and also trying to set up a link so that User can download the Spreadsheeet on their computer. My first problem was how to retrieve my data from the databse and save it in an array. Secondly, i could not use write method as well as landScape method. It will help if you can clear me up on those issues. Thanks!<br />
Kalyan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
