Location: PHPKode > scripts > PHPExcel wrapper for populating XLS files with user data > printform-xls.ru.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>printform-xls : Êëàññ-îáåðòêà äëÿ çàïîëíåíèÿ ôîðì â ôîðìàòå XLS (PHPExcel)
</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<style type="text/css">
<!--
body     { font-family:verdana,arial,helvetica;font-size:12px; }
pre { font-family: verdana,arial; font-size:11px; color:#0000FF;
      background-color: #EFEFF0; border: 1px solid #D0D0F0; padding:6px;
}
td   { font-family:arial,helvetica;font-size:11px;}
td.head  { background-color: #FBFBFE; border: 1px solid #ccf; font-weight:bold; padding-left:6px;}
tr.odd   { background-color: #F0F0F8; }
tr.even  { background-color: #E7E7F5; }
h4       { background-color: #E0E0F0; text-align: left; font-size:12px; }
h5       { background-color: #E0E0F0; text-align: left; font-size:11px; padding-left:8px;}
.red     { color:red; font-weight: bold;}
.details { background-color: #fbfbff; border: 1px solid #ccf; margin: 20px 10px; padding:8px; }
-->
</style>
</head>
<body>
<!-- DOC BEGIN -->

<h3>printform-xls : Êëàññ-îáåðòêà äëÿ çàïîëíåíèÿ ôîðì â ôîðìàòå XLS (PHPExcel)</h3>

<p>
Íàçíà÷åíèå êëàññà CPrintFormXls - ãåíåðàöèÿ XLS-ôàéëîâ ñ ïîëüçîâàòåëüñêèìè äàííûìè íà îñíîâå ïîäãîòîâëåííûõ øàáëîíîâ.
Íà ëèñòû âûõîäíîãî ôàéëà ôîðìàòà MS Excel (è íà âåñü ôàéë) ìîæåò ïîñòàâëåíà ïàðîëüíàÿ çàùèòà.
<br />Ñîáñòâåííî äëÿ ÷òåíèÿ èñõîäíîãî XLS ôàéëà øàáëîíà, çàíåñåíèÿ â íåãî ïîëüçîâàòåëüêñèõ äàííûõ è ñîõðàíåíèÿ ðåçóëüòàòà
èñïîëüçóåòñÿ èçâåñòíûé íàáîð êëàññîâ PHPExcel (äèñòðèáóòèâ PHPExcel íåîáõîäèìî ñàìîñòîÿòåëüíî ñêà÷àòü
ñ <a href="http://www.codeplex.com/PHPExcel" target="_blank">ñàéòà ðàçðàáîò÷èêîâ (codeplex.com)</a> è óñòàíîâèòü
íà ñâîé  WEB-ñåðâåð).

</p>

<br />Â òåêóùåé âåðñèè êëàññ èìååò ñëåäóþùèé ôóíêöèîíàë:
<ul>
  <li>Àâòîìàòè÷åñêàÿ êîíâåðòàöèÿ èñõîäíûõ "òåêñòîâûõ" çíà÷åíèé â êîäèðîâêó UTF-8 (òðåáóåìóþ ôîðìàòîì XLS).
  <br />Äîñòàòî÷íî óêàçàòü characet set èñõîäíûõ äàííûõ.
  </li>
  <li>Ïîääåðæêà ïîëüçîâàòåëüñêèõ ôóíêöèé äëÿ ïðåîáðàçîâàíèÿ îòäåëüíûõ äàííûõ ê íóæíîìó âèäó, ïåðåä çàíåñåíèåì â XLS.
  </li>
  <li>Ïîääåðæêà çíà÷åíèé ôîðìàòà "Äàòà" (date): ñòðîêîâûå çíà÷åíèÿ â ôîðìàòàõ 'ÄÄ.ÌÌ.ÃÃÃÃ' èëè 'ÃÃÃÃ-ÌÌ-ÄÄ'
  àâòîìàòè÷åñêè ïðåîáðàçóþòñÿ ê "âíóòðåííåìó" ÷èñëîâîìó ôîðìàòó äàííûõ â Excel. Ìîæíî óêàçûâàòü ñâîé âûõîäíîé ôîðìàò äàò (òèïà 'dd/mm/yyyy').
  </li>
  <li>Ïîääåðæêà XLS ôàéëîâ ñ íåñêîëüêèìè ëèñòàìè.
  </li>
  <li>Ïàðîëüíàÿ çàùèòà ëèñòîâ è âñåãî XLS ôàéëà îò èçìåíåíèÿ, (íàñêîëüêî ýòî ïîääåðæèâàåòñÿ â PHPExcel).
  </li>
  <li>Ñïèñîê çàïîëíÿåìûõ ÿ÷ååê - "ïîëåé" ñ èõ ïîçèöèÿìè íà ëèñòàõ, à òàêæå äðóãèå ïàðàìåòðû ðàáîòû, çàäàþòñÿ â XML-ôàéëå êîíôèãóðàöèè
   (çàïîëíÿåòñÿ âðó÷íóþ)
  </li>
</ul>

<h4>Ïðèìåð : Ñîçäàåì XLS ôàéë èç øàáëîíà è ñâîèõ äàííûõ</h4>

<br /><br />Íàïîìíèì, ÷òî PHP-ìîäóëè PHPExcel íåîáõîäèìî ðàçìåñòèòü íà ñâîåì ñåðâåðå, è ïàïêó ñ ðàñïîëîæåííûì ôàéëîì PHPExcel.php
äîáàâèòü â ñâîé php.ini-ïàðàìåòð "<b>include_path</b>"
(ïðè ðàáîòå íà ïëîùàäêå ïðîâàéäåðà, êîãäà äîñòóïà ê PHP.ini íåò, êàê îáû÷íî ñïàñåò ôóíêöèÿ  set_include_path() ).

<pre>
require_once('PHPExcel.php');
require_once('PHPExcel/IOFactory.php');
require_once('PHPExcel/Reader/Excel5.php'); # èëè äðóãîé ôàéë, åñëè íóæåí âûâîä â Excel 2007 è ò.ï.
</pre>

Ïðåäïîëîæèì, ó íàñ ïîäãîòîâëåí ôàéë øàáëîíà template-test.xls, à òàêæå åñòü ñëåäóþùèé ôàéë êîíôèãóðàöèè cfg-test.xml:

<pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;printdef&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;description&gt;sample format for testing&lt;/description&gt;
  &lt;dateformat&gt;dd/mm/yyyy&lt;/dateformat&gt;
  &lt;stringcharset&gt;WINDOWS-1251&lt;/stringcharset&gt;
  &lt;templatefile&gt;config-test.xls&lt;/templatefile&gt;
  &lt;sheets&gt;
   &lt;sheet offset="0"&gt;
    &lt;field name="last_name" col="3" row="5" type="string" convert="AddBraces" /&gt;
    &lt;field name="first_name" col="3" row="7" type="string"/&gt;
    &lt;field name="birthdate" col="3" row="9" type="date"/&gt;
    &lt;field name="address" col="3" row="11" type="string"/&gt;
    &lt;field name="resident" col="3" row="13" type="bool"/&gt;
    &lt;field name="resident" col="5" row="15" type="bool-invert"/&gt;
   &lt;/sheet&gt;
  &lt;/sheets&gt;
&lt;/printdef&gt;
</pre>

Ñîçäàíèå çàïîëíåííîãî XLS ôàéëà ïðîèñõîäèò â ñëåäóþùåì ñêðèïòå:
<pre>
require_once('PHPExcel.php'); // We use PHPExcel classes !
require_once('PHPExcel/IOFactory.php');
require_once('PHPExcel/Reader/Excel5.php');
require_once('printform-xls.php');

$excel = new CPrintFormXls(array(
   'configfile' =&gt; 'cfg-test.xml'
  ,'outname' =&gt; 'myfile-test.xls'
  ,'resident' =&gt; 1
));

# íàøè äàííûå :
$data = array(
   'last_name'=&gt;'Smirnoff'
  ,'first_name' =&gt; 'Ivan'
  ,'birthdate'  =&gt; '1970-04-18'
  ,'address'     =&gt;'Russia, Moscow, Usacheva street, 33-999'
  ,'resident'   =&gt; 1
);

$excel-&gt;AddData($data); // XLS çàïîëíèòñÿ ýòèìè äàííûìè äàííûìè
$ok = $excel-&gt;Render(); // ãåíåðèðóåò è âûâîäèò ôàéë

if(!$ok) echo $excel-&gt;GetErrorMessage(); // ÷òî-òî ïîøëî íå òàê ? Âûâåñòè ïîñëåäíþþ îøèáêó
exit;

// íàøà ô-öèÿ äëÿ äàííûõ last_name
function AddBraces($param) {
    return "[ $param ]";
}
</pre>

<h4>CPrintFormXls : ñïèñîê ìåòîäîâ</h4>

<b>CPrintFormXls($param='' [, $data [, $outname [, $tofile]]])</b> - êîíñòðóêòîð êëàññà.
<br />$param - èëè ñòðîêà (ïåðåäàåò ïóòü/èìÿ êîíôèãóðàöèîííîãî XML ôàéëà), èëè (ïðåäïî÷òèòåëüíûé ñïîñîá) -
<br />àññîöèàòèâíûé ìàññèâ ñî âñåìè íóæíûìè ïàðàìåòðàìè

<br />
<table>
<tr>
  <td class="head">Êëþ÷</td><td class="head">Íàçíà÷åíèå</td>
</tr>
<tr class="odd">
  <td><b>template</b>
  </td>
  <td>Ïóòü/Èìÿ ôàéëà XLS øàáëîíà.
  </td>
</tr>

<tr class="even">
  <td><b>outname</b>
  </td>
  <td>Èìÿ ñîçäàâàåìîãî ôàéëà. Åñëè ïåðåäàí íåíóëåâîé ïàðàìåòð "tofile", ôàéë áóäåò ñîõðàíåí ïîä ýòèì èìåíåì.
  </td>
</tr>

<tr class="odd">
  <td><b>tofile</b>
  </td>
  <td>Ïî óìîë÷àíèþ ñîäåðæèìîå ñîçäàííîãî ôàéëà ïîñûëàåòñÿ â áðàóçåð êëèåíòà (ïîëüçîâàòåëü óâèäèò çàïðîñ íà îòêðûòèå èëè ñîõðàíåíèå ôàéëà).
    Åñëè ïåðåäàòü íåíóëåâîå çíà÷åíèå â ïàðàìåòðå 'tofile', ôàéë áóäåò ñîõðàíåí íà äèñêå,
    áåç âûâîäà â "ïîòîê" ê êëèåíòó.
  </td>
</tr>

<tr class="even">
  <td><b>configfile</b>
  </td>
  <td>Ïîëíûé ïóòü/èìÿ êîíôèãóðàöèîííîãî XML ôàéëà, õðàíÿùåãî âñå íàñòðîéêè âûâîäà (èìåíà ïîëåé äàííûõ è èõ ïîçèöèè íà ëèñòàõ XLS,
  è äðóãèå ïàðàìåòðû (ñì. <a href="#XML_config">îïèñàíèå ôàéëà</a>).
  Åñëè ïàðàìåòð íå çàäàí ïðè âûçîâå êíîñòðóêòîðà, âàì ïðèäåòñÿ ïîçäíåå âûçâàòü ìåòîä LoadConfig().
  </td>
</tr>

<tr class="odd">
  <td><b>outfmt</b>
  </td>
  <td>Ôîðìàò (è òèï) âûõîäíîãî ôàéëà. Äîïóñòèì ëþáîé ôîðìàò, ïîääåðæèâàåìûé êëàññàìè PHPExcel.
  Åñëè âû çàäàåòå ëþüîé ôîðìàò, îòëè÷íûé îò 'Excel5', ñîîòâåòñòâåííî âû äîëæíû ïîäêëþ÷èòü ñîîòâåòñòâóþùèå ìîäóëè
  èç êîìïëåêòà PHPExcel (Include, require, incude_once è ò.ä.)

  <br /> ÷àñòíîñòè äîïóñòèì ôîðìàò 'pdf'. Ò.ê. PHPExcel óæå ñîäåðæèò êëàññû CPDF äëÿ çàïèñè â PDF ôàéë, îí ìîæåò áûòü
  âûáðàí êàê âûõîäíîé ôîðìàò.
  Îäíàêî ýòà îïöèÿ òåñòèðîâàëàñü òîëüêî íà ïðîñòûõ XLS øàáëîíàõ, ïðè ãåíåðàöèè PDF èç "ñëîæíûõ" ôàéëîâ XLS çàìå÷åíû çàâèñàíèÿ.
  </td>
</tr>

<tr class="even">
  <td><b>protectsheets</b>
  </td>
  <td>Âêëþ÷àåò çàùèòó âñåõ ëèñòîâ âûõîäíîãî XLS ôàéëà. Ó÷òèòå, ÷òî èñõîäíûé XLS ôàéë íå äîëæåí áûòü çàùèùåí !
  Êðîìå òîãî, ðåæèì çàùèòû ëèñòîâ ìîæíî îòäåëüíî âêëþ÷àòü/âûêëþ÷àòü ìåòîäîì ProtectSheets().
  </td>
</tr>

<tr class="odd">
  <td><b>password</b>
  </td>
  <td>Îáùèé ïàðîëü íà âñå ëèñòû, èñïîëüçóåìûé ïðè âêëþ÷åíèè çàùèòû.
  </td>
</tr>

<tr class="even">
  <td><b>protectbook</b>
  </td>
  <td>Âêëþ÷àåò ðåæèì çàùèòû êíèãè ('1' èëè true äëÿ âêëþ÷åíèÿ ðåæèìà)
  Òàêæå åñòü îòäåëüíûé ìåòîä ProtectBook() äëÿ ïåðåêëþ÷åíèÿ ðåæèìà.
  </td>
</tr>

<tr class="odd">
  <td><b>bookpassword</b>
  </td>
  <td>Ïàðîëü äëÿ çàùèòû êíèãè.
  </td>
</tr>

<tr class="even">
  <td><b>data</b>
  </td>
  <td>Àññîöèàòèâíûé ìàññèâ äàííûõ äëÿ çàïîëíåíèÿ øàáëîíà.
  Åñëè íå ïåðåäàí â êîíñòðóêòîðå, ïîçäíåå ìîæíî âûçâàòü AddData().
  </td>
</tr>

</table>

<br /><br />
<b>LoadConfig($cfgname)</b> çàãðóæàåò ïàðàìåòðû èç XML-ôàéëà êîíôèãóðàöèè. Ôàéë ïîäãîòàâëèâàåòñÿ â ñëåäóþùåì ôîðìàòå:

<br /><br /><a name="XML_config">Ôàéë êîíôèãóðàöèè (XML)</a>
<pre>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;printdef&gt;
  &lt;version&gt;1.0&lt;/version&gt; /* âåðñèÿ ôîðìàòà */
  &lt;description&gt;sample format for testing&lt;/description&gt; /* íå ñèïîëüçóåòñÿ, ïðîñòî äëÿ èíôîðìàöèè */
  &lt;dateformat&gt;dd/mm/yyyy&lt;/dateformat&gt;         /* ôîðìàò âûâîäà äàòû â êîíå÷íîì XLS ôàéëå, ïî óìîë÷àíèþ - 'dd/mm/yyyy' */
  &lt;stringcharset&gt;WINDOWS-1251&lt;/stringcharset&gt;   /* êîäèðîâêà ñòðî÷íûõ èñõîäíûõ äàííûõ */
  &lt;templatefile&gt;config-test.xls&lt;/templatefile&gt;  /* ïóòü/èìÿ ôàéëà øàáëîíà XLS */
  &lt;protectsheets&gt;1&lt;/protectsheets&gt; /* âêëþ÷èòü çàùèòó ëèñòîâ */
  &lt;protectpassword&gt;mypassword&lt;/protectpassword&gt; /* ïàðîëü äëÿ ëèñòîâ */
  &lt;sheets&gt; /* Çàäàíèå çàïîëíÿåìûõ ïîëåé äàííûõ */
   &lt;sheet offset="0"&gt; /* offset - 0-based íîìåð ëèñòà â ôàéëå øàáëîíà */
    /* Àòðèáóòû: "name" - èìÿ ïîëÿ; "col" íîìåð êîëîíêè (0-based); "row" - íîìåð ñòðîêè (1-based) */
    &lt;field name="last_name" col="3" row="5" type="string" convert="AddBraces" /&gt;
    &lt;field name="birthday" col="3" row="11" type="date"/&gt;
    /* etc... */
   &lt;/sheet&gt;
  &lt;/sheets&gt;
&lt;/printdef&gt;

</pre>
Âìåñòî èìåíè XML-ôàéëà ìîæíî ïåðåäàâàòü ñîáñòâåííî XML-áëîê äàííûõ (well formed XML, ñîîòâåòñòâóþùèé îïèñàííîìó ôîðìàòó).

<br />
Êàæäûé ëèñò êíèãè Excel äîëæåí èìåòü àòðèáóò "offset", çàäàþùèé 0-based íîìåð ëèñòà â èñõîäíîì XLS ôàéëå øàáëîíà.

<br /><br />Àòðèáóòû òåãà "field" :
<br /><b>name</b> - èìÿ ïîëÿ. Â ïåðåäàííîì ìàññèâå äàííûõ - êëþ÷ ýëåìåíòà.
<br /><b>col</b> - íîìåð êîëîíêè, 0-based (íà÷èíàåòñÿ ñ íóëÿ).
<br /><b>row</b> - íîìåð ñòðîêè, 1-based.
<br /><b>type</b> - íåîáÿçàòåëüíûé - òèï ïîëÿ (ïî óìîë÷àíèþ ñ÷èòàåòñÿ string).

<div class="details">
type: ïîääåðæèâàåìûå òèïû - "<b>string</b>", "<b>date</b>", "<b>bool</b>" è "<b>bool-invert</b>".
Åñëè "date" çíà÷åíèÿ îêàçûâàþòñÿ ñòðîêîé, â êëàññå äåëàåòñÿ àâòî-êîíâåðòàöèÿ èç âîçìîæíûõ ôîðìàòîâ 'yyyy-mm-dd', 'yy/dd/yyyy' è 'dd.mm.yyyy'
âî "âíóòðåííèé" öåëî÷èñëåííûé âèä XLS-äàòû (íîìåð äíÿ íà÷èíàÿ ñ 01.01.1900). Åñëè ïåðåäàíî ÷èñëîâîå çíà÷åíèå, îíî  íå êîíâåðòèðóåòñÿ - ñ÷èòàåòñÿ,
÷òî ïðîãðàììèñò ñàìîñòîÿòåëüíî ïðèâåë äàòó ê ÷èñëîâîìó XLS-ôîðìàòó.

<br /><br />"<b>bool</b>" òèï : ëþáîå íå-íóëåâîå çíà÷åíèå ïðåâðàùàåòñÿ â ñèìâîë 'X' â ñîîòâåòñòâóþùåé XLS-ÿ÷åéêå, â ïðîòèâíîì ñëó÷àå âûâîäèòñÿ ïðîáåë.
<br />"<b>bool-invert</b>" äåëàåò îáðàòíîå: åäèíè÷íîå (íå-íóëåâîå) çíà÷åíèå ñòàíåò ïðîáåëîì, è íîëü - ñèìâîëîì 'X'  -
áëàãîäàðÿ ýòîìó òèïà ìîæíî ñ ïîìîùüþ åäèíñòâåííîãî ýëåìåíòà â äàííûõ óïðàâëÿòü äâóìÿ âûõîäíûìè ÿ÷åéêàìè.
Íàïðèìåð, ýòî ìîæåò ïðèãîäèòüñÿ äëÿ ôîðìèðîâàíèÿ ïîëåé òèïà "ðåçèäåíò ÐÔ" - ÄÀ [<b>X</b>] - ÍÅÒ [ ].
</div>

<br /><b>convert</b> - íåîáÿçàòåëüíûé àòðèáóò, çàäàþùèé èìÿ ôóíêöèè êîíâåðòîðà, âûçûâàåìîé íàä ïåðåäàííûì çíà÷åíèåì è âîçâðàùàþùåé "êîíâåðòèðîâàííîå"
     çíà÷åíèå. Ôóíêöèÿ áóäåò âûçâàíà ïåðåä àâòî-êîíâåðòàöèåé char-set-à è ïîìåùåíèåì äàííûõ â XLS .

<br /><br /><b>AddData($param, $pval=null)</b> - ìåòîä äîáàâëÿåò áëîê äàííûõ äëÿ âûâîäà â XLS ôàéë.
$param ìîæåò áûòü ñòðîêîé, ñîäåðæàùåé èìÿ ïîëÿ ( â ýòîì ñëó÷àå âî âòîðîì ïàðàìåòðå ïåðåäàåòñÿ çíà÷åíèå).
Èëè $param ìîæåò áûòü àññîöèàòèâíûì ìàññèâîì â ôîðìàòå èìÿ_ïîëÿ =&gt; çíà÷åíèå.

<br />AddData() ìîæåò áûòü âûçâàí íåñêîëüêî ðàç (äî âûçîâà ôèíàëüíîãî Render() ), äàííûå â èòîãå íàêàïëèâàþòñÿ.

<br /><br /><b>ProtectSheets($protect, $password='')</b> âêëþ÷àåò ($protect=1 èëè true) èëè âûêëþ÷àåò (0|false) çàùèòó ëèñòîâ,
ñ ïåðåäà÷åé ïàðîëÿ.

<br /><br /><b>ProtectBook($protect, $password=null)</b> âêëþ÷àåò ($protect=1 èëè true) èëè âûêëþ÷àåò (0|false) çàùèòó "êíèãè" XLS.
<br /><span class='red'>ÂÍÈÌÀÍÈÅ</span>: Çàìå÷åíî, ÷òî çàùèòà êíèãè ìîæåò íå ðàáîòàòü (èñïîëüçóåìàÿ âåðñèÿ PHPExcel - 1.7.3c),
ïîýòîìó ïåðåä ïðèìåíåíèåì íóæäàåòñÿ â äîïîëíèòåëüíîì òåñòèðîâàíèè.

<br /><br /><b>Render()</b> âûïîëíÿåò ôèíàëüíóþ ãåíåðàöèþ âûõîäíîãî XLS ôàéëà ñ âûâîäîì â áðàóçåð ëèáî ñîõðàíåíèåì íà äèñê.

<br /><br /><b>GetErrorMessage()</b> âîçâðàùàåò ñòðîêó ñ ïîñëåäíåé ïðîèçîøåäøåé îøèáêîé, åñëè îíà âîçíèêëà.

<br /><br /><b>GetXlsObject()</b> âîçâðàùàåò âíóòðåííèé îáúåêò êëàññà PHPExcel, ÷òîáû ïðîãðàììèñò ìîã íàïðÿìóþ ðàáîòàòü íàä íèì ñ ïîìîùüþ âûçîâîâ
ìåòîäîâ èç êëàññîâ PHPExcel, íàïðèìåð, çàïèñàòü â XLS ôàéë äîïîëíèòåëüíûå çíà÷åíèÿ ÿ÷ååê, ñìåíèòü ïàðàìåòðû ôàéëà, ëèñòà è ò.ä.

<h4>Ïðèìåðû èñïîëüçîâàíèÿ</h4>

Ïðèìåð 1. Çàùèùàåì ëèñòû ïàðîëåì
<pre>
$excel = new CPrintFormXls(array(
   'configfile' =&gt; 'cfg-test.xml'
  ,'outname' =&gt; 'myfile-test.xls'
));

$data = array(
   'last_name'=&gt;'Smirnoff'
  ,'first_name' =&gt; 'Ivan'
# ...
);
$excel-&gt;AddData($data);

$excel =&gt;ProtectSheets(true,'mypassword'); // âêëþ÷àåì çàùèòó ëèñòîâ ïàðîëåì

$ok = $excel-&gt;Render();
</pre>

Ïðèìåð 2. Âûâîäèì â PDF-ôàéë
<pre>
$excel = new CPrintFormXls(array(
   'configfile' =&gt; 'cfg-test.xml'
  ,'outname' =&gt; 'myfile-test.<b>pdf</b>' // Set correct output file extension
  ,'outfmt' =&gt; 'pdf' // set output format to PDF
));

$data = array(
   'last_name'=&gt;'Smirnoff'
  ,'first_name' =&gt; 'Ivan'
# ...
);
$excel-&gt;AddData($data);
$ok = $excel-&gt;Render();
</pre>
Ïðèìå÷àíèå: ââèäó îãðàíè÷åíèé PHP-êëàññîâ CPDF âèä ãîòîâîãî PDF ôàéëà ìîæåò ñóùåñòâåííî îòëè÷àòüñÿ îò "äâîéíèêà" XLS.


<br /><br />Ïðèìåð 3. Ðàáîòà ñ îáúåêòîì PHPExcel íàïðÿìóþ.
<pre>
$excel = new CPrintFormXls(array(
   'configfile' =&gt; 'cfg-test.xml'
  ,'outname' =&gt; 'myfile-test.xls'
));
# ...

$xlsobj = $excel-&gt;GetXlsObject();
$xlsobj-&gt;getSheet(0)-&gt;setCellValueByColumnAndRow(3, 17, 'This text inserted outside class !');

$excel-&gt;AddData($data);
$ok = $excel-&gt;Render();
</pre>

<br /><br />
<div style="text-align:right">Ðàñïðîñòðàíÿåòñÿ ïî ëèöåíçèè <a href="http://www.opensource.org/licenses/bsd-license.php">BSD</a></div>


<h4>Ññûëêè</h4>
<ul>
  <li><a href="http://www.codeplex.com/PHPExcel" target="_blank">Êëàññû PHPExcel</a>
  </li>
</ul>

<h4>Èñòîðèÿ</h4>

<h5>1.01.005 (13.07.2010)</h5>
<ul>
  <li>Çàïðîñ íîâîãî ôóíêöèîíàëà: ìåòîä LoadConfig() êðîìå èìåíè XML-ôàéëà êîíôèãóðàöèè ìîæåò ïðèíèìàòü XML-ñîäåðæèìîå äëÿ ïàðñèíãà
  (äîëæíà áûòü ñòðîêà ñîäåðæàùàÿ well formed XML)
  </li>
</ul>

<h5>1.00.004 (07.07.2010)</h5>
<ul>
  <li>Ïåðâûé ðåëèç
  </li>
</ul>

<!-- DOC END -->
<br />
<hr>
<div align=center><font size=-2>Copyright &copy; 2010 Alexander Selifonov, <a href="http://www.selifan.ru">www.selifan.ru</a>
</font></div>
</body></html>
Return current item: PHPExcel wrapper for populating XLS files with user data