Subversion Repositories eFlore/Applications.cel

Rev

Rev 970 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 970 Rev 1604
Line 2... Line 2...
2
/*
2
/*
3
*  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
3
*  Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
4
*
4
*
5
*  PERL Spreadsheet::WriteExcel module.
5
*  PERL Spreadsheet::WriteExcel module.
6
*
6
*
7
*  The author of the Spreadsheet::WriteExcel module is John McNamara 
7
*  The author of the Spreadsheet::WriteExcel module is John McNamara
8
*  <jmcnamara@cpan.org>
8
*  <jmcnamara@cpan.org>
9
*
9
*
10
*  I _DO_ maintain this code, and John McNamara has nothing to do with the
10
*  I _DO_ maintain this code, and John McNamara has nothing to do with the
11
*  porting of this code to PHP.  Any questions directly related to this
11
*  porting of this code to PHP.  Any questions directly related to this
12
*  class library should be directed to me.
12
*  class library should be directed to me.
Line 29... Line 29...
29
*    You should have received a copy of the GNU Lesser General Public
29
*    You should have received a copy of the GNU Lesser General Public
30
*    License along with this library; if not, write to the Free Software
30
*    License along with this library; if not, write to the Free Software
31
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
*/
32
*/
Line 33... Line 33...
33
 
33
 
34
//require_once('PEAR.php');
34
require_once 'PEAR.php';
Line 35... Line 35...
35
require_once('Writer/Workbook.php');
35
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
36
 
36
 
37
/**
37
/**
38
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
38
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
Line 63... Line 63...
63
    * @access public
63
    * @access public
64
    */
64
    */
65
    function send($filename)
65
    function send($filename)
66
    {
66
    {
67
        header("Content-type: application/vnd.ms-excel");
67
        header("Content-type: application/vnd.ms-excel");
68
        header("Content-Disposition: attachment; filename=$filename");
68
        header("Content-Disposition: attachment; filename=\"$filename\"");
69
        header("Expires: 0");
69
        header("Expires: 0");
70
        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
70
        header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
71
        header("Pragma: public");
71
        header("Pragma: public");
72
    }
72
    }
Line -... Line 73...
-
 
73
 
-
 
74
    /**
-
 
75
    * Utility function for writing formulas
-
 
76
    * Converts a cell's coordinates to the A1 format.
-
 
77
    *
-
 
78
    * @access public
-
 
79
    * @static
-
 
80
    * @param integer $row Row for the cell to convert (0-indexed).
-
 
81
    * @param integer $col Column for the cell to convert (0-indexed).
-
 
82
    * @return string The cell identifier in A1 format
-
 
83
    */
-
 
84
    function rowcolToCell($row, $col)
-
 
85
    {
-
 
86
        if ($col > 255) { //maximum column value exceeded
-
 
87
            return new PEAR_Error("Maximum column value exceeded: $col");
-
 
88
        }
-
 
89
 
-
 
90
        $int = (int)($col / 26);
-
 
91
        $frac = $col % 26;
-
 
92
        $chr1 = '';
-
 
93
 
-
 
94
        if ($int > 0) {
-
 
95
            $chr1 = chr(ord('A') + $int - 1);
-
 
96
        }
-
 
97
 
-
 
98
        $chr2 = chr(ord('A') + $frac);
-
 
99
        $row++;
-
 
100
 
-
 
101
        return $chr1 . $chr2 . $row;
73
 
102
    }
74
}
103
}