<!DOCTYPE html>
	<html lang="vi" xmlns="http://www.w3.org/1999/xhtml" prefix="og: http://ogp.me/ns#">
	<head>
<title>Thêm một hàm xuất dữ liệu ra file Excel trong module nukeviet.</title>
<meta name="description" content="Thêm một hàm xuất dữ liệu ra file Excel trong module nukeviet. - Savefile - Tin tức -...">
<meta name="author" content="BÀI TẬP Ở NHÀ">
<meta name="copyright" content="BÀI TẬP Ở NHÀ [ducluu80@gmail.com]">
<meta name="robots" content="index, archive, follow, noodp">
<meta name="googlebot" content="index, archive, follow, noodp">
<meta name="msnbot" content="all,index,follow">
<meta name="generator" content="NukeViet v4.5">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="vi">
<meta property="og:title" content="Thêm một hàm xuất dữ liệu ra file Excel trong module nukeviet.">
<meta property="og:type" content="website">
<meta property="og:description" content="Savefile - Tin tức - https&#x3A;&#x002F;&#x002F;baitaponha.com&#x002F;savefile&#x002F;thu-thuat-may-tinh&#x002F;them-mot-ham-xuat-du-lieu-ra-file-excel-trong-module-nukeviet-30.html">
<meta property="og:site_name" content="BÀI TẬP Ở NHÀ">
<meta property="og:url" content="https://baitaponha.com/savefile/thu-thuat-may-tinh/them-mot-ham-xuat-du-lieu-ra-file-excel-trong-module-nukeviet-30.html">
<link rel="shortcut icon" href="https://baitaponha.com/uploads/logo.ico">
<link rel="canonical" href="https://baitaponha.com/savefile/thu-thuat-may-tinh/them-mot-ham-xuat-du-lieu-ra-file-excel-trong-module-nukeviet-30.html">
<link rel="alternate" href="https://baitaponha.com/rss/" title="Tin tức" type="application/rss+xml">
<link rel="alternate" href="https://baitaponha.com/rss/lap-trinh-python-co-ban/" title="Tin tức - Lập trình Python cơ bản." type="application/rss+xml">
<link rel="alternate" href="https://baitaponha.com/rss/giai-de-tin-hoc/" title="Tin tức - Giải đề tin học" type="application/rss+xml">
<link rel="alternate" href="https://baitaponha.com/rss/boi-gioi-tin-hoc/" title="Tin tức - Bồi giỏi tin học" type="application/rss+xml">
<link rel="alternate" href="https://baitaponha.com/rss/lap-trinh-c/" title="Tin tức - Lập trình C++" type="application/rss+xml">
<link rel="alternate" href="https://baitaponha.com/rss/thu-thuat-may-tinh/" title="Tin tức - Thủ thuật máy tính" type="application/rss+xml">
<link rel="preload" as="style" href="https://baitaponha.com/assets/css/font-awesome.min.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/bootstrap.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/style.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/style.non-responsive.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/custom.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/style-green.css" type="text/css">
<link rel="preload" as="style" href="https://baitaponha.com/themes/egov/css/news.css" type="text/css">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/jquery/jquery.min.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/language/vi.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/DOMPurify/purify3.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/global.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/site.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/themes/default/js/news.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/assets/js/jquery/jquery.cookie.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/themes/egov/js/main.js" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/themes/egov/js/custom.js" type="text/javascript">
<link rel="preload" as="script" href="https://www.googletagmanager.com/gtag/js?id=G-4JBZJ8SEPL" type="text/javascript">
<link rel="preload" as="script" href="https://baitaponha.com/themes/egov/js/bootstrap.min.js" type="text/javascript">
<link rel="StyleSheet" href="https://baitaponha.com/assets/css/font-awesome.min.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/bootstrap.non-responsive.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/style.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/style.non-responsive.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/custom.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/style-green.css">
<link rel="StyleSheet" href="https://baitaponha.com/themes/egov/css/news.css">
<style type="text/css">
	body{background: #fff;}
</style>

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3247389617576546"
     crossorigin="anonymous"></script>
     <!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4JBZJ8SEPL"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-4JBZJ8SEPL');
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W4C9RPT');</script>
<!-- End Google Tag Manager -->
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-6V0WCB5SCB"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-6V0WCB5SCB');
</script>
<script async custom-element="amp-auto-ads"
        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
</script>		
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-262364265-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-262364265-1');
</script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-262364265-1', '.baitaponha.com');
ga('send', 'pageview');
</script>
</head>
	<body>
	    <amp-auto-ads type="adsense"
                    data-ad-client="ca-pub-3247389617576546">
        </amp-auto-ads>
<!-- BEGIN Fanpage Facebook -->
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=v16.0&appId=390459604647856&autoLogAppEvents=1" nonce="H8AT1lQt"></script>

<!-- END Fanpage Facebook -->
        <!-- Google Tag Manager (noscript) -->
            <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W4C9RPT"
            height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
        <!-- End Google Tag Manager (noscript) -->
<div id="print">
	<div id="hd_print">
		<h2 class="pull-left">BÀI TẬP Ở NHÀ</h2>
		<p class="pull-right"><a title="BÀI TẬP Ở NHÀ" href="https://baitaponha.com/">https://baitaponha.com</a></p>
	</div>
	<div class="clear"></div>
	<hr />
	<div id="content">
		<h1>Thêm một hàm xuất dữ liệu ra file Excel trong module nukeviet.</h1>
		<ul class="list-inline">
			<li>Thứ năm - 27/04/2023 21:35</li>
			<li class="hidden-print txtrequired"><em class="fa fa-print">&nbsp;</em><a title="In ra" href="javascript:;" onclick="window.print()">In ra</a></li>
			<li class="hidden-print txtrequired"><em class="fa fa-power-off">&nbsp;</em><a title="Đóng cửa sổ này" href="javascript:;" onclick="window.close()">Đóng cửa sổ này</a></li>
		</ul>
		<div class="clear"></div>
		<div id="hometext">
						<div class="pull-left imghome">
				<img alt="Xuất dữ liệu ra Excel" src="https://baitaponha.com/assets/news/2023_04/screenshot-2023-04-30-090309.png" width="100" class="img-thumbnail" />
								<p>
					<em>Xuất dữ liệu ra Excel</em>
				</p>
			</div>
			Xuất dữ liệu từ MySQL Database luôn là một nhu cầu rất cần thiết đối với nhiều website, vì vậy tôi xin hướng dẫn các bạn cách để thêm một chức năng xuất dữ liệu ra file Excel trong module Nukeviet. Trong bài viết này chúng ta sẽ thực hiện xuất dữ liệu từ module users ra Excel. Còn đối với các module khác các bạn thực hiện tương tự.
		</div>
		<div id="bodytext" class="clearfix">
			<h2><strong>Phần 1.</strong></h2>

<h2 style="text-align: center;"><iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/gNRxyZf5x7c" title="YouTube video player" width="560"></iframe></h2>

<h2><br />
<strong>Phần 2:</strong></h2>

<h2 style="text-align: center;"><iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/ifyxfnE5w_k" title="YouTube video player" width="560"></iframe></h2>

<h2><strong>Bước 1. Tạo file xuatex.tpl lưu vào thư mục : themes\admin_default\modules\users\</strong></h2>
Bạn vào thư mục theme mặc định của admin là&nbsp;<strong>themes\admin_default\modules\users\&nbsp;</strong>tạo một file có tên là <strong>xuatex.tpl</strong> có nội dung sau:

<pre>
<code class="language-html">&lt;!-- BEGIN: main --&gt;
&lt;form action=&quot;/admin/index.php?{NV_LANG_VARIABLE}={NV_LANG_DATA}&amp;amp;{NV_NAME_VARIABLE}={MODULE_NAME}&amp;amp;{NV_OP_VARIABLE}={OP}&quot; method=&quot;post&quot;&gt;
    &lt;div class=&quot;text-left&quot;&gt;&lt;input class=&quot;btn btn-primary&quot; name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;{LANG.xuat}&quot; /&gt;&lt;/div&gt;
&lt;/form&gt;
&lt;!-- END: main --&gt;</code></pre>
File này chỉ hiển thị nút bấm vào để xuất ra excel.

<h3>&nbsp;</h3>

<h2><strong>Bước 2. Tạo file xuatex.php lưu vào thư mục: modules\users\admin\</strong></h2>
Tiếp theo các bạn vào thư mục&nbsp;<strong>modules\users\admin\&nbsp;</strong>tạo file <strong>xuatex.php</strong> có nội dung như sau:

<pre>
<code class="language-php">&lt;?php

/**
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC &lt;contact@vinades.vn&gt;
 * @Copyright (C) 2020 VINADES.,JSC. All rights reserved
 * @License: Not free read more http://nukeviet.vn/vi/store/modules/nvtools/
 * @Createdate Sat, 31 Oct 2020 02:20:33 GMT
 */

if (!defined(&#039;NV_IS_FILE_ADMIN&#039;)) {
    die(&#039;Stop!!!&#039;);
}

$page_title = $lang_module&#91;&#039;xuatex&#039;&#93;;

//------------------------------
// Viết code xử lý chung vào đây
//------------------------------

$xtpl = new XTemplate(&#039;xuatex.tpl&#039;, NV_ROOTDIR . &#039;/themes/&#039; . $global_config&#91;&#039;module_theme&#039;&#93; . &#039;/modules/&#039; . $module_file);
$xtpl-&gt;assign(&#039;LANG&#039;, $lang_module);
$xtpl-&gt;assign(&#039;NV_LANG_VARIABLE&#039;, NV_LANG_VARIABLE);
$xtpl-&gt;assign(&#039;NV_LANG_DATA&#039;, NV_LANG_DATA);
$xtpl-&gt;assign(&#039;NV_BASE_ADMINURL&#039;, NV_BASE_ADMINURL);
$xtpl-&gt;assign(&#039;NV_NAME_VARIABLE&#039;, NV_NAME_VARIABLE);
$xtpl-&gt;assign(&#039;NV_OP_VARIABLE&#039;, NV_OP_VARIABLE);
$xtpl-&gt;assign(&#039;MODULE_NAME&#039;, $module_name);
$xtpl-&gt;assign(&#039;OP&#039;, $op);

//-------------------------------
// Viết code xuất ra site vào đây
//-------------------------------
$xtpl-&gt;parse(&#039;main&#039;);
$contents = $xtpl-&gt;text(&#039;main&#039;);

include NV_ROOTDIR . &#039;/includes/header.php&#039;;
echo nv_admin_theme($contents);
include NV_ROOTDIR . &#039;/includes/footer.php&#039;;</code></pre>
Nội dung file này chưa xử lý gì, mà đây chỉ là cấu hình cơ bản của một chức năng trong admin.

<h3>&nbsp;</h3>

<h2><strong>Bước 3. Thêm ngôn ngữ trong admin.</strong>&nbsp;</h2>
Việc tiếp theo là thêm ngôn ngữ vào file ngôn ngữ trong thư mục mặc định theme admin: Vào thư mục&nbsp;<strong>modules\users\language\&nbsp;</strong>tìm file <strong>admin_vi.php&nbsp;</strong>mở ra và thêm vào cuối cùng đoạn mã sau:

<pre>
<code class="language-php">$lang_module&#91;&#039;xuatex&#039;&#93; = &#039;Xuất dữ liệu ra Excel&#039;;
$lang_module&#91;&#039;xuat&#039;&#93; = &#039;Bấm để xuất dữ liệu ra Excel&#039;;</code></pre>

<h3><strong><span id="cke_bm_3928S" style="display: none;">&nbsp;</span></strong><br />
&nbsp;</h3>

<h2><strong>Bước 4. Thêm chức năng vào menu trong quản lý admin của module.</strong>&nbsp;</h2>
Ở bước này các bạn tìm file: <strong>admin.menu.php</strong> trong thư mục&nbsp;<strong>modules/users/admin.menu.php&nbsp;</strong>mở và tìm:

<pre>
<code class="language-php">$allow_func&#91;&#93; = &#039;config&#039;;</code></pre>
Thêm vào ngay dưới dòng lệnh sau:

<pre>
<code class="language-php">$submenu&#91;&#039;xuatex&#039;&#93; = $lang_module&#91;&#039;xuatex&#039;&#93;;
$allow_func&#91;&#93; = &#039;xuatex&#039;;</code></pre>

<p><span id="cke_bm_4710S" style="display: none;">&nbsp;</span><br />
Đến đây cơ bản đã thêm được một hàm&nbsp; trong admin. Vào lại phần quản lý module users trong admin để xem kết quả:</p>

<h3><img alt="Screenshot 2023 04 30 090309" height="297" src="https://baitaponha.com/uploads/news/2023_04/screenshot-2023-04-30-090309.png" width="441" /><br />
<br />
&nbsp;</h3>

<h2><strong>Bước 5. Viết các lệnh xử lý để xuất dữ liệu ra Excel.</strong></h2>

<pre>
<code class="language-php">&lt;?php

if (!defined(&#039;NV_IS_FILE_ADMIN&#039;)) {
    die(&#039;Stop!!!&#039;);
}

$page_title = $lang_module&#91;&#039;xuatex&#039;&#93;;

if (!class_exists(&#039;PHPExcel&#039;)) {
    if (file_exists(NV_ROOTDIR . &#039;/includes/class/PHPExcel.php&#039;)) {
        require_once NV_ROOTDIR . &#039;/includes/class/PHPExcel.php&#039;;
    } 
}
if (!class_exists(&#039;PHPExcel&#039;)) {
    $contents = nv_theme_alert(&#039;LỖI RỒI&#039;, &#039;Lỗi thiếu class PHPExcel, Bạn hãy tải PHPExcel vào trong thư mục includes&#039;, &#039;danger&#039;);
    include NV_ROOTDIR . &#039;/includes/header.php&#039;;
    echo nv_admin_theme($contents);
    include NV_ROOTDIR . &#039;/includes/footer.php&#039;;
}
//------------------------------
// Viết code xử lý chung vào đây
//------------------------------
$xtpl = new XTemplate(&#039;xuatex.tpl&#039;, NV_ROOTDIR . &#039;/themes/&#039; . $global_config&#91;&#039;module_theme&#039;&#93; . &#039;/modules/&#039; . $module_file);
$xtpl-&gt;assign(&#039;LANG&#039;, $lang_module);
$xtpl-&gt;assign(&#039;GLANG&#039;, $lang_global);
$xtpl-&gt;assign(&#039;ACTION_URL&#039;, NV_BASE_ADMINURL . &#039;index.php?&#039; . NV_LANG_VARIABLE . &#039;=&#039; . NV_LANG_DATA . &#039;&amp;&#039; . NV_NAME_VARIABLE . &#039;=&#039; . $module_name . &#039;&amp;&#039; . NV_OP_VARIABLE);
$xtpl-&gt;assign(&#039;OP&#039;, $op);

//-------------------------------
// Viết code xuất ra site vào đây
//-------------------------------
$post = $nv_Request-&gt;get_title(&#039;submit&#039;, &#039;post&#039;, &#039;&#039;);
if (!empty($post)){
	$objExcel = new PHPExcel;
	$objExcel-&gt;setActiveSheetIndex(0);
	// Đặt tên Sheet là Xuất dữ liệu.
	$sheet = $objExcel-&gt;getActiveSheet()-&gt;setTitle(&#039;Xuất dữ liệu&#039;);
	//--Tạo tiêu đề các cột A, B, C, D... bắt đầu từ hàng 4 trong Excel.
	$rowCount = 4;
	$sheet-&gt;setCellValue(&#039;A&#039;.$rowCount,&#039;STT&#039;);
	$sheet-&gt;setCellValue(&#039;B&#039;.$rowCount,&#039;TÊN ĐĂNG NHẬP&#039;);
	$sheet-&gt;setCellValue(&#039;C&#039;.$rowCount,&#039;EMAIL&#039;);
	$sheet-&gt;setCellValue(&#039;D&#039;.$rowCount,&#039;HỌ VÀ TÊN ĐỆM&#039;);
	$sheet-&gt;setCellValue(&#039;E&#039;.$rowCount,&#039;TÊN&#039;);
	$sheet-&gt;setCellValue(&#039;F&#039;.$rowCount,&#039;NGÀY SINH&#039;);
	$sheet-&gt;setCellValue(&#039;G&#039;.$rowCount,&#039;GIỚI TÍNH&#039;);
	//Lấy dữ liệu từ MySQL:
	$sql_query = &quot;SELECT * FROM nv4_users&quot;;
	$resultset = $db-&gt;query($sql_query);
	//Chèn dữ liệu vào file Excel.
	$stt = 1;
	foreach($resultset as $developer) {
		$rowCount++;
		$sheet-&gt;setCellValue(&#039;A&#039;.$rowCount,$stt);
		$sheet-&gt;setCellValue(&#039;B&#039;.$rowCount,$developer&#91;&#039;username&#039;&#93;);
		$sheet-&gt;setCellValue(&#039;C&#039;.$rowCount,$developer&#91;&#039;email&#039;&#93;);
		$sheet-&gt;setCellValue(&#039;D&#039;.$rowCount,$developer&#91;&#039;last_name&#039;&#93;);
		$sheet-&gt;setCellValue(&#039;E&#039;.$rowCount,$developer&#91;&#039;first_name&#039;&#93;);
		$developer&#91;&#039;birthday&#039;&#93; = nv_date(&#039;d/m/Y&#039;, $developer&#91;&#039;birthday&#039;&#93;);
		$sheet-&gt;setCellValue(&#039;F&#039;.$rowCount,$developer&#91;&#039;birthday&#039;&#93;);
		$sheet-&gt;setCellValue(&#039;G&#039;.$rowCount,$developer&#91;&#039;gender&#039;&#93;);
		$stt++;
		}
	//--Set độ rộng cột A là tự động.
		$sheet-&gt;getColumnDimension(&#039;A&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;B&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;C&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;D&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;E&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;F&#039;)-&gt;setAutoSize(true);
		$sheet-&gt;getColumnDimension(&#039;G&#039;)-&gt;setAutoSize(true);
	//--Căn giữa hàng tiêu đề A4:G4.
		$sheet-&gt;getStyle(&#039;A4:G4&#039;)-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
	// Set border Từ A4 đến G cuối cùng +1
			$styleArray = array(
				&#039;borders&#039; =&gt; array(
					&#039;allborders&#039; =&gt; array(
						&#039;style&#039; =&gt; PHPExcel_Style_Border::BORDER_THIN,
						&#039;color&#039; =&gt; array(
							&#039;argb&#039; =&gt; &#039;FF000000&#039;
						)
					)
				)
			);
			$sheet-&gt;getStyle(&#039;A4&#039; . &#039;:&#039; . &#039;G&#039;.($rowCount+1))-&gt;applyFromArray($styleArray);
	//Set font size.	
			$sheet-&gt;getStyle(&#039;A1&#039;.&#039;:&#039;.&#039;G&#039;.($rowCount+1))
					-&gt;getFont()-&gt;setBold(false)
                    -&gt;setName(&#039;Times New Roman&#039;)
                    -&gt;setSize(14);
	// Tai file vừa tạo về máy.
	$objWriter = new PHPExcel_Writer_Excel2007($objExcel);
	$filename = &#039;xuatex.xlsx&#039;;
	$objWriter-&gt;save($filename);
	header(&#039;Content-Disposition: attachment; filename=&quot;&#039;.$filename.&#039;&quot;&#039;);
	header(&#039;Content-Type: application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet&#039;);
	header(&#039;Content-Length: &#039; . filesize($filename));
	header(&#039;Content-Transfer-Encoding: binary&#039;);
	header(&#039;Cache-Control: must-revalidate&#039;);
	header(&#039;Pragma: no-cache&#039;);
	readfile($filename);
}

$xtpl-&gt;parse(&#039;main&#039;);
$contents = $xtpl-&gt;text(&#039;main&#039;);

include NV_ROOTDIR . &#039;/includes/header.php&#039;;
echo nv_admin_theme($contents);
include NV_ROOTDIR . &#039;/includes/footer.php&#039;;</code></pre>
&nbsp; Và đây là thành quả khi xuất ra:<br />
<img alt="Screenshot 2023 05 02 234619" height="279" src="https://baitaponha.com/uploads/news/2023_04/screenshot-2023-05-02-234619.png" width="854" />
		</div>
				<div id="author">
						<p>
				<strong>Tác giả:</strong>
				<a href="https://baitaponha.com/author/admin/">admin</a>
			</p>
		</div>
	</div>
	<div id="footer" class="clearfix">
		<div id="url">
			<strong>URL của bản tin này: </strong><a href="https://baitaponha.com/savefile/thu-thuat-may-tinh/them-mot-ham-xuat-du-lieu-ra-file-excel-trong-module-nukeviet-30.html" title="Thêm một hàm xuất dữ liệu ra file Excel trong module nukeviet.">https://baitaponha.com/savefile/thu-thuat-may-tinh/them-mot-ham-xuat-du-lieu-ra-file-excel-trong-module-nukeviet-30.html</a>

		</div>
		<div class="clear"></div>
		<div class="copyright">
			&copy; BÀI TẬP Ở NHÀ
		</div>
		<div id="contact">
			<a href="mailto:ducluu80@gmail.com">ducluu80@gmail.com</a>
		</div>
	</div>
</div>
        <div id="timeoutsess" class="chromeframe">
            Bạn đã không sử dụng Site, <a onclick="timeoutsesscancel();" href="https://baitaponha.com/#">Bấm vào đây để duy trì trạng thái đăng nhập</a>. Thời gian chờ: <span id="secField"> 60 </span> giây
        </div>
        <div id="openidResult" class="nv-alert" style="display:none"></div>
        <div id="openidBt" data-result="" data-redirect=""></div>
<script src="https://baitaponha.com/assets/js/jquery/jquery.min.js"></script>
<script>var nv_base_siteurl="/",nv_lang_data="vi",nv_lang_interface="vi",nv_name_variable="nv",nv_fc_variable="op",nv_lang_variable="language",nv_module_name="news",nv_func_name="savefile",nv_is_user=0, nv_my_ofs=-4,nv_my_abbr="EDT",nv_cookie_prefix="btol",nv_check_pass_mstime=21538000,nv_area_admin=0,nv_safemode=0,theme_responsive=0,nv_recaptcha_ver=2,nv_recaptcha_sitekey="",nv_recaptcha_type="image",XSSsanitize=1;</script>
<script src="https://baitaponha.com/assets/js/language/vi.js"></script>
<script src="https://baitaponha.com/assets/js/DOMPurify/purify3.js"></script>
<script src="https://baitaponha.com/assets/js/global.js"></script>
<script src="https://baitaponha.com/assets/js/site.js"></script>
<script src="https://baitaponha.com/themes/default/js/news.js"></script>
<script src="https://baitaponha.com/assets/js/jquery/jquery.cookie.js"></script>
<script src="https://baitaponha.com/themes/egov/js/main.js"></script>
<script src="https://baitaponha.com/themes/egov/js/custom.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4JBZJ8SEPL"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date);gtag('config','G-4JBZJ8SEPL');</script>
<script src="https://baitaponha.com/themes/egov/js/bootstrap.min.js"></script>
</body>
</html>