__wbook = new \Shuchkin\SimpleXLSXGen(); $this->__wbook ->setAuthor($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER']) ->setLastModifiedBy($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER']) ->setTitle($oprop['title'] ?? "") ->setSubject($oprop['subject'] ?? $_SESSION['__WEB_APP']['REG_NAME']) ->setDescription($oprop['desc'] ?? "") ->setCompany($_SESSION['__WEB_APP']['REG_NAME']) ->setDefaultFont("Calibri") ->setDefaultFontSize(11); } private function coord2cell($x, $y) { $c = ''; for ($i = $x; $i >= 0; $i = ((int)($i / 26)) - 1) { $c = chr(ord('A') + $i % 26) . $c; } return $c . ($y + 1); } private function create_style($tstyle="L") { $_astyle = explode(",", $tstyle); $_s_style = ""; $_e_style = ""; foreach ($_astyle as $_key => $_val) { if ($_val == "L") {$_s_style .= ''; $_e_style .= '';} if ($_val == "R") {$_s_style .= ''; $_e_style .= '';} if ($_val == "C") {$_s_style .= '
'; $_e_style .= '
';} if ($_val == "W") {$_s_style .= ''; $_e_style .= '';} if ($_val == "B") {$_s_style .= ''; $_e_style .= '';} if ($_val == "I") {$_s_style .= ''; $_e_style .= '';} if ($_val == "S") {$_s_style .= "\0"; $_e_style .= '';} if ($_val == "N") {$_s_style .= '';} if ($_val == "N0") {$_s_style .= '';} } return ['s'=>$_s_style, 'e'=>$_e_style]; } public function clear_field() { $this->__atabel = []; } public function add_header($tjudul="") { if ($tjudul=="") return; $this->__aheader[] = $tjudul; } public function add_empty_row($nrow=1) { $_jkolom = count($this->__atabel); for ($i=0; $i<$nrow; $i++) { $this->__avalue[] = array_fill(0,$_jkolom,""); } } public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") { $this->__atabel[] = [$tnama, $nlebar, $ffunc]; $this->__astyle[] = $this->create_style($talign); } public function add_sheet($tnama_sheet="BARU", $bw_header=true) { $this->__tsheet = $tnama_sheet; $_jkolom = count($this->__atabel); foreach ($this->__aheader as $_key => $_val) { $a_out = ['"]; $this->__amerge[] = $this->coord2cell(0, count($this->__avalue)) . ":" . $this->coord2cell($_jkolom-1, count($this->__avalue)); $this->__avalue[] = $a_out; } if ($bw_header==true) $this->show_headers(); } public function add_value() { $tmp_arr = func_get_args(); if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; $a_out = []; for ($i=0; $i__atabel); $i++) { $tmp_val = $tmp_arr[$i]; if (is_array($this->__atabel[$i][2]) && trim($tmp_val)<>"") { $tmp_val = $this->__atabel[$i][2][$tmp_val]; } else if (function_exists($this->__atabel[$i][2]) && trim($tmp_val)<>"") { $tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val); } $a_out[] = $this->__astyle[$i]['s'] . $tmp_val . $this->__astyle[$i]['e']; } $this->__avalue[] = $a_out; } public function add_span() { $tmp_arr = func_get_args(); $a_out = []; for ($i=0; $i"") { $tmp_val[0] = call_user_func($tmp_val[3], $tmp_val[0]); } } $tmp_style = $this->create_style($tmp_val[2]); if ($tmp_val[1]>1) $this->__amerge[] = $this->coord2cell(count($a_out), count($this->__avalue)) . ":" . $this->coord2cell((count($a_out)+$tmp_val[1])-1, count($this->__avalue)); $a_out[] = $tmp_style['s'] . $tmp_val[0] . $tmp_style['e']; for ($k=1; $k<$tmp_val[1]; $k++) $a_out[] = null; } $this->__avalue[] = $a_out; } public function add_stamp($ctk_ke=1, $bnama=false) { $this->__avalue[] = ["".$_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"").""]; } public function get_stamp($ctk_ke=1, $bnama=false) { return $_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):""); } public function show_headers() { $a_out = []; for ($i=0; $i__atabel); $i++) { $a_out[] = ''; } $this->__avalue[] = $a_out; } public function send($tnama_file="File_Excel") { $this->__wbook->addSheet($this->__avalue, $this->__tsheet); for ($i=0; $i__atabel); $i++) { $this->__wbook->setColWidth(($i+1), $this->__atabel[$i][1]); } for ($i=0; $i__amerge); $i++) { $this->__wbook->mergeCells($this->__amerge[$i]); } $this->__wbook->downloadAs($tnama_file); } } ?>