Class luya\yii\helpers\XLSXWriter_BuffererWriter
| Inheritance | luya\yii\helpers\XLSXWriter_BuffererWriter |
|---|---|
| Source Code | https://github.com/luyadev/yii-helpers/blob/master/src/helpers/XLSXWriter_BuffererWriter.php |
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $buffer | luya\yii\helpers\XLSXWriter_BuffererWriter | ||
| $check_utf8 | luya\yii\helpers\XLSXWriter_BuffererWriter | ||
| $fd | luya\yii\helpers\XLSXWriter_BuffererWriter |
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| isValidUTF8() | luya\yii\helpers\XLSXWriter_BuffererWriter | |
| purge() | luya\yii\helpers\XLSXWriter_BuffererWriter |
Property Details
Method Details
| public void __construct ( $filename, $fd_fopen_flags = 'w', $check_utf8 = false ) | ||
| $filename | ||
| $fd_fopen_flags | ||
| $check_utf8 | ||
public function __construct($filename, $fd_fopen_flags = 'w', $check_utf8 = false)
{
$this->check_utf8 = $check_utf8;
$this->fd = fopen($filename, $fd_fopen_flags);
if ($this->fd === false) {
XLSXWriter::log("Unable to open $filename for writing.");
}
}
| public void close ( ) |
public function close()
{
$this->purge();
if ($this->fd) {
fclose($this->fd);
$this->fd = null;
}
}
| public void fseek ( $pos ) | ||
| $pos | ||
public function fseek($pos)
{
if ($this->fd) {
$this->purge();
return fseek($this->fd, $pos);
}
return -1;
}
| public void ftell ( ) |
public function ftell()
{
if ($this->fd) {
$this->purge();
return ftell($this->fd);
}
return -1;
}
| protected static void isValidUTF8 ( $string ) | ||
| $string | ||
protected static function isValidUTF8($string)
{
if (function_exists('mb_check_encoding')) {
return mb_check_encoding($string, 'UTF-8') ? true : false;
}
return preg_match("//u", $string) ? true : false;
}
| protected void purge ( ) |
protected function purge()
{
if ($this->fd) {
if ($this->check_utf8 && !self::isValidUTF8($this->buffer)) {
XLSXWriter::log("Error, invalid UTF8 encoding detected.");
$this->check_utf8 = false;
}
fwrite($this->fd, $this->buffer);
$this->buffer = '';
}
}
| public void write ( $string ) | ||
| $string | ||
public function write($string)
{
$this->buffer .= $string;
if (isset($this->buffer[8191])) {
$this->purge();
}
}