export to excel openable in Microsoft Excel and Open office

2011-01-21 Thread rakeshyadav rakeshyadav
Hi all,

i am trying to export my data to excel in binary xls format using
below helper

http://bakery.cakephp.org/articles/view/excel-xls-helper
*
* The difference compared with the original one is this helper
* actually creates an xml which is openable in Microsoft Excel.
*
* Written by Yuen Ying Kit @ ykyuen.wordpress.com
*
*/


class XlsHelper extends AppHelper {




/**
* set the header of the http response.
*
* @param unknown_type $filename
*/
function setHeader($filename) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Type: application/force-download");
header("Content-Type: application/download");;
header("Content-Disposition: inline; filename=\"".$filename.".xls\"");
}

/**
* add the xml header for the .xls file.
*
*/
function addXmlHeader() {
echo "\n";
echo "\n";
return;
}

/**
* add the worksheet name for the .xls.
* it has to be added otherwise the xml format is incomplete.
*
* @param unknown_type $workSheetName
*/
function setWorkSheetName($workSheetName) {
echo "\n";
echo "\n";
return;
}

/**
* add the footer to the end of xml.
* it has to be added otherwise the xml format is incomplete.
*
*/
function addXmlFooter() {
echo "\t\n";
echo "\t\n";
echo "\n";
return;
}

/**
* move to the next row in the .xls.
* must be used with closeRow() in pair.
*
*/
function openRow() {
echo "\t";
return;
}
function splitRow($Value){

echo "#808000".$Value;
return;
}


/**
* end the row in the .xls.
* must be used with openRow() in pair.
*
*/
function closeRow() {
echo "\t\n";
return;
}

/**
* Write the content of a cell in number format
*
* @param unknown_type $Value
*/
function writeNumber($Value) {
if (is_null($Value)) {
echo "\t ";
} else {

echo "\t".$Value;
}
return;
}

/**
* Write the content of a cell in string format
*
* @param unknown_type $Value
*/
function writeString($Value) {

echo "\t".$Value;

return;
}


}
?>

but i don't know how to get colors to cell and how to split the cell if
anyone use this helper please tell me how to get my requirements if u use
any other functions  in this helper please post it.

Thanks

A. Rakesh

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Export to Excel

2009-08-24 Thread Braindead

There are at least 2 articles in the bakery that describe how to
create a real Excel file (no csv):

http://bakery.cakephp.org/articles/view/generate-excel-spreadsheets-from-your-database
http://bakery.cakephp.org/articles/view/excel-xls-helper

Personally I use the second one and it works quite good.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Export to Excel

2009-08-23 Thread Martin Westin


There is a trick that almost makes me love Microsoft... You can export
an html table to Excel. Just output a table, maybe some heading before
and a p-tag after if you like... no layout... no full html document
needed. Just make the browser think this html table is an excel file
and Excel will happily import it.

That is: Set the header to application/vnd.ms-excel and/or the
filename to something.xls

CSV is a very good format to export to since it is can be imported to
any number of applications and databases. But if Excel is all you want
I like the simple cheat with the table.


On Aug 23, 10:54 am, delocalizer  wrote:
> Adam Royle's csv helper is very nice for 
> this...http://bakery.cakephp.org/articles/view/csv-helper-php5
>
> cheers,
> Conrad.
>
> On Aug 23, 12:41 am, AMF  wrote:
>
>
>
> > I've been looking for a good tutorial/exaple on exporting data to
> > excel like format.
>
> > Any success/ideas/pinters.
>
> > Thanks
>
> > AMF
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Export to Excel

2009-08-23 Thread delocalizer

Adam Royle's csv helper is very nice for this...
http://bakery.cakephp.org/articles/view/csv-helper-php5

cheers,
Conrad.

On Aug 23, 12:41 am, AMF  wrote:
> I've been looking for a good tutorial/exaple on exporting data to
> excel like format.
>
> Any success/ideas/pinters.
>
> Thanks
>
> AMF
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Export to Excel

2009-08-22 Thread AMF


I've been looking for a good tutorial/exaple on exporting data to
excel like format.

Any success/ideas/pinters.

Thanks

AMF

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---