function PHPExcel_Writer_Excel5_Worksheet::_writeUrlExternal in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php \PHPExcel_Writer_Excel5_Worksheet::_writeUrlExternal()
* Write links to external directory names such as 'c:\foo.xls', * c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'. * * Note: Excel writes some relative links with the $dir_long string. We ignore * these cases for the sake of simpler code. * * @access private * *
Parameters
integer $row1 Start row: * @param integer $col1 Start column * @param integer $row2 End row * @param integer $col2 End column * @param string $url URL string * @return integer
See also
_writeUrl()
1 call to PHPExcel_Writer_Excel5_Worksheet::_writeUrlExternal()
- PHPExcel_Writer_Excel5_Worksheet::_writeUrlRange in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Worksheet.php - * This is the more general form of _writeUrl(). It allows a hyperlink to be * written to a range of cells. This function also decides the type of hyperlink * to be written. These are either, Web (http, ftp, mailto), Internal * (Sheet1!A1) or…
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Worksheet.php, line 1124
Class
- PHPExcel_Writer_Excel5_Worksheet
- PHPExcel_Writer_Excel5_Worksheet
Code
function _writeUrlExternal($row1, $col1, $row2, $col2, $url) {
// Network drives are different. We will handle them separately
// MS/Novell network drives and shares start with \\
if (preg_match('[^external:\\\\]', $url)) {
return;
//($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
}
$record = 0x1b8;
// Record identifier
$length = 0x0;
// Bytes to follow
// Strip URL type and change Unix dir separator to Dos style (if needed)
//
$url = preg_replace('/^external:/', '', $url);
$url = preg_replace('/\\//', "\\", $url);
// Determine if the link is relative or absolute:
// relative if link contains no dir separator, "somefile.xls"
// relative if link starts with up-dir, "..\..\somefile.xls"
// otherwise, absolute
$absolute = 0x0;
// relative path
if (preg_match('/^[A-Z]:/', $url)) {
$absolute = 0x2;
// absolute path on Windows, e.g. C:\...
}
$link_type = 0x1 | $absolute;
// Determine if the link contains a sheet reference and change some of the
// parameters accordingly.
// Split the dir name and sheet name (if it exists)
$dir_long = $url;
if (preg_match("/\\#/", $url)) {
$link_type |= 0x8;
}
// Pack the link type
$link_type = pack("V", $link_type);
// Calculate the up-level dir count e.g.. (..\..\..\ == 3)
$up_count = preg_match_all("/\\.\\.\\\\/", $dir_long, $useless);
$up_count = pack("v", $up_count);
// Store the short dos dir name (null terminated)
$dir_short = preg_replace("/\\.\\.\\\\/", '', $dir_long) . "\0";
// Store the long dir name as a wchar string (non-null terminated)
$dir_long = $dir_long . "\0";
// Pack the lengths of the dir strings
$dir_short_len = pack("V", strlen($dir_short));
$dir_long_len = pack("V", strlen($dir_long));
$stream_len = pack("V", 0);
//strlen($dir_long) + 0x06);
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack("H*", 'D0C9EA79F9BACE118C8200AA004BA90B02000000');
$unknown2 = pack("H*", '0303000000000000C000000000000046');
$unknown3 = pack("H*", 'FFFFADDE000000000000000000000000000000000000000');
$unknown4 = pack("v", 0x3);
// Pack the main data stream
$data = pack("vvvv", $row1, $row2, $col1, $col2) . $unknown1 . $link_type . $unknown2 . $up_count . $dir_short_len . $dir_short . $unknown3 . $stream_len;
/*.
$dir_long_len .
$unknown4 .
$dir_long .
$sheet_len .
$sheet ;*/
// Pack the header data
$length = strlen($data);
$header = pack("vv", $record, $length);
// Write the packed data
$this
->_append($header . $data);
return 0;
}