PHP : Generate Excel file

<?php

$header = array(‘First Name’,’Last Name’,’About you Description’);

// Create a array having xls information to print. It could be get from database.
$xls_data_to_print = array(
‘0’=>array(
‘first_name’=> ‘John’,
‘last_name’=> ‘Rawal’,
‘about_info’=> ‘He is a great player.’,
),

‘1’=>array(
‘first_name’=> ‘John1’,
‘last_name’=> ‘Rawal1’,
‘about_info’=> ‘He is a great player1.’,
),

);
$xls_content_row = ”;
foreach($xls_data_to_print as $xls_ky => $xls_val){
// Write a code here to generate XLS file with required details.
// Use $xls_val->title OR $xls_val[‘title’] depending array type.
$rows = array();
$rows[]= $xls_val[‘first_name’];
$rows[]= $xls_val[‘last_name’];
$rows[]= $xls_val[‘about_info’];

$xls_content_row .= implode(“\t”, array_values($rows)) . “\r\n”;
}
$xls_content_header = implode(“\t”, array_values($header));
$xls_content = $xls_content_header.”\n”.$xls_content_row;
$filename = ‘Xls_data_list_’.date(“d_m_Y”);
header(“Content-type: text/plain; charset=UTF-8”);
header(“Content-Disposition: attachment; filename=$filename”);
header(“Content-Type: application/vnd.ms-excel”);
header(“Pragma: no-cache”);
header(“Expires: 0”);
print $xls_content;
die();

Magento : Create New Layout For CMS Pages

  1. Create PHTML file on your theme at app\design\frontend\theme\default\template\cms\file_name.phtml
  2. Add XML code in layouts app\design\frontend\theme\default\layout\page.xml here you add the xml code like:

    <page_one_column translate=”label”>
    <label>All One-Column Layout Pages</label>
    <reference name=”root”>
    <action method=”setTemplate”><template>page/1column.phtml</template></action>
    <!– Mark root page block that template is applied –>
    <action method=”setIsHandle”><applied>1</applied></action>
    </reference>
    </page_one_column>

  3. then add layout name at app\code\core\Mage\Page\etc\config.xml Like:

    <one_column module=”page” translate=”label”>
                        <label>1 column</label>
                        <template>page/1column.phtml</template>
                        <layout_handle>page_one_column</layout_handle>
                        <is_default>1</is_default>
       </one_column>