Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 3.141.27.70
<?php
// Microsoft Excel 5 Header and End Of File Binary Representation
define('XLSFile_Header', pack("s*", 2057, 8, 0, 0, 0, 0));
define('XLSFile_End', pack("s*", 10, 0));
// Following function return code for an Excel Worksheet Cell
function get_xlscell_code($x, $y, $cell_txt) {
$ret = pack("s*", 516, strlen($cell_txt) + 8, $y, $x, 0, strlen($cell_txt));
$ret .= $cell_txt;
return $ret;
}
class XLS {
var $final_bytes = '';
var $file_name = 'text.xls';
function add_cell($COLUMN, $ROW, $cell_text) {
$this->final_bytes .= get_xlscell_code($COLUMN, $ROW, $cell_text);
}
function xls_bytes() {
return XLSFile_Header.$this->final_bytes.XLSFile_End;
}
function save_file($fname = '') {
$fname = $fname == '' ? $this->file_name : $fname;
$f = fopen($fname, 'wb');
if (!$f) return false;
$bytes = $this->xls_bytes();
if (!fwrite($f,$bytes)) return false;
fclose($f);
return true;
}
function leave_only_chars($str) {
$str = strToLower($str);
$pattern = '/[^a-z_]*/';
return preg_replace($pattern, '', $str);
}
}
?>
|