adding setTempDir() for setting a different temp dir than the default when creating OLE files

git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@146617 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Xavier Noguer Gallego 2003-12-16 20:56:54 +00:00
parent 9acd764192
commit 29f21aed74
1 changed files with 30 additions and 1 deletions

View File

@ -159,6 +159,12 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
*/
var $_country_code;
/**
* The temporary dir for storing the OLE file
* @var string
*/
var $_tmp_dir;
/**
* Class constructor
*
@ -194,6 +200,7 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
$this->_str_unique = 0;
$this->_str_table = array();
$this->_setPaletteXl97();
$this->_tmp_dir = '';
}
/**
@ -541,6 +548,22 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
return true;
}
/**
* Sets the temp dir used for storing the OLE file
*
* @access public
* @param string $dir The dir to be used as temp dir
* @return true if given dir is valid, false otherwise
*/
function setTempDir($dir)
{
if (is_dir($dir)) {
$this->_tmp_dir = $dir;
return true;
}
return false;
}
/**
* Store the workbook in an OLE container
*
@ -550,6 +573,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
function _storeOLEFile()
{
$OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book'));
if ($this->_tmp_dir != '') {
$OLE->setTempDir($this->_tmp_dir);
}
$res = $OLE->init();
if ($this->isError($res)) {
return $this->raiseError("OLE Error: ".$res->getMessage());
@ -563,6 +589,9 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
}
}
$root = new OLE_PPS_Root(time(), time(), array($OLE));
if ($this->_tmp_dir != '') {
$root->setTempDir($this->_tmp_dir);
}
$res = $root->save($this->_filename);
if ($this->isError($res)) {
return $this->raiseError("OLE Error: ".$res->getMessage());