本文整理汇总了PHP中io::array_to_excel方法的典型用法代码示例。如果您正苦于以下问题:PHP io::array_to_excel方法的具体用法?PHP io::array_to_excel怎么用?PHP io::array_to_excel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io
的用法示例。
在下文中一共展示了io::array_to_excel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
//.........这里部分代码省略.........
if (isset($this->header['description'])) {
$header[$sheet][] = [$this->header['description']];
}
$header[$sheet][] = [' '];
$temp = $header;
// displaying filter
if (isset($this->header['filter'])) {
$temp2 = [];
foreach ($this->header['filter'] as $k => $v) {
$temp[$sheet][] = [strip_tags($k), strip_tags($v)];
}
$temp[$sheet][] = [' '];
}
// converting data
foreach ($this->data as $k => $v) {
$temp2 = [];
foreach ($v['d'] as $k2 => $v2) {
if (is_array($v2)) {
$value = $v2['v'] ?? null;
} else {
$value = $v2;
}
// replaces
$value = str_replace(' ', ' ', $value);
$temp2[] = strip_tags($value);
}
$temp[$sheet][] = $temp2;
}
// get output buffering
helper_ob::clean_all();
// content
switch ($type) {
case 'xlsx':
echo io::array_to_excel($temp, io::$formats[$type]['excel_code'], null);
break;
default:
// csv or text
header('Content-Type: ' . numbers_frontend_exports_csv_base::$formats[$type]['content_type']);
header('Content-Disposition: attachment; filename="' . $sheet . '.' . $type . '"');
header('Cache-Control: max-age=0');
echo numbers_frontend_exports_csv_base::array_to_csv($temp, numbers_frontend_exports_csv_base::$formats[$type]['delimiter'], numbers_frontend_exports_csv_base::$formats[$type]['enclosure']);
}
exit;
break;
case 'html':
case 'html2':
default:
// rendering data
$table = ['options' => []];
$counter = 1;
foreach ($this->data as $k => $v) {
$flag_colspan = 0;
$row = [];
if (!empty($v['d'])) {
foreach ($v['d'] as $k2 => $v2) {
if ($flag_colspan > 0) {
$flag_colspan--;
continue;
}
$colspan = '';
if ($v2['c'] ?? null) {
$colspan = $v2['c'];
$flag_colspan = $v2['c'] - 1;
}
$align = 'left';
$title = '';