/** +---------------------------------------------------------- * Import the required class library with Java * This function has the function of caching +---------------------------------------------------------- * @param string $class Class library namespace strings * @param string $BASEURL start path * @param string $ext imported file name extensions +---------------------------------------------------------- * @return Boolen +---------------------------------------------------------- */ Function Import ($class, $baseUrl = ', $ext = '. class.php ') { Static $_file = Array (); $class = str_replace (Array ('. ', ' # '), Array ('/', '. '), $class); if (' = = = $baseUrl && false = = = Strpos ($class, '/')) { Check alias Import Return Alias_import ($class); } if (Isset ($_file[$class. $baseUrl])) return true; Else $_file[$class. $baseUrl] = true; $class _strut = explode ('/', $class); if (empty ($BASEURL)) { if (' @ ' = = $class _strut[0] | | App_name = = $class _strut[0]) { Load the current Project Application class Library $BASEURL = DirName (Lib_path); $class = Substr_replace ($class, basename (lib_path). ' /', 0, strlen ($class _strut[0]) + 1); }elseif (' think ' = = Strtolower ($class _strut[0])) {//Think official base Class library $BASEURL = Core_path; $class = substr ($class, 6); }elseif (In_array (Strtolower ($class _strut[0]), array (' org ', ' com ')) { Org third party public class library COM enterprise public class Library $BASEURL = Library_path; }else {//Load other Project Application class library $class = Substr_replace ($class, ", 0, strlen ($class _strut[0]) + 1); $BASEURL = App_path. '.. /' . $class _strut[0]. '/'. basename (Lib_path). ' /'; } } if (substr ($BASEURL,-1)! = '/') $baseUrl. = '/'; $classfile = $baseUrl. $class. $ext; if (!class_exists (basename ($class), false)) { Import the class library file if the class does not exist Return Require_cache ($classfile); } } /** * Export Excel Table * @param array $data data, two-dimensional array, one record per piece of data * @param array $title The field names of each column of data, and the arrays must be consistent with the data order (can be omitted) * @param string $filename Excel name * @param array $field need to specify the exported data field, the sort must match the title, that is, and the array key value of the data is isolated */ function Exportexcel ($data = ', $title = ', $filename = ' Excel ', $field =array ()) { if (! $data | |!is_array ($DATA)) return false; if ($filename = = ") $filename = ' Excel '; if ($field && Is_array ($field)) {//As long as the specified fields are exported and exported in this order $dateNew =array (); foreach ($data as $k = = $v) { foreach ($field as $fkey) { $dateNew [$k] [$fkey]= $v [$fkey]; } } $data = $dateNew; } Import ("@.org.util.excelxml");//Call Export Excel Class $xls = new Excelxml (' UTF-8 ', false, ' Sheet1 '); $xls->addarray ($data, $title); $xls->generatexml ($filename); } |