本文介绍了数据没有从数据库导出到excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想从数据库中获取数据并导出到EXCEL文件。我的数据将正确地出现但不能出口到EXCEL文件......只是头部只显示不是数据........以下是我的代码。请更正代码或告诉他们怎么做 error_reporting(E_ALL ^ E_NOTICE); require_once(excelwriter.class.php); $ dt = date(dmY); $ fileName =AmountWise。$ dt; $ excel = new ExcelWriter($ fileName.xls); if($ excel == false) echo $ excel->错误; $ excel-> writeLine($ myArr); $ myArr = array(Sr.No。,Net ID,RC,Defaulter Ka Naam,Bank / Vibhag Name,Rashi,Duestype); $ excel-> writeLine($ myArr); if($ _ POST ['amountfrom']!='' && $ _POST ['amountto']!=''&& $ tehsil == 0){ echo $ sqlentry12 =select * from rcentry amount BETWEEN。$ _ POST ['amountto']。AND。$ _ POST ['amountfrom']。; } else if($ _POST ['amount from']!=''&& $ _POST ['amountto']!=''&& $ tehsil!= 0) { echo $ sqlentry12 =select * from rcentry tehsil ='。$ tehsil。'和amount BETWEEN。$ _ POST ['amountto']。 AND。$。$ [POST ['amountfrom']。; } $ query12 = $ db-> query($ sqlentry12); if(query12!= false){ $ k = 1; $ i = 0; while($ rowdata = $ db-> fetchObject()){ $ bgcolor = getBgColor($ i ++); $ vibhag = getRecordbyId('vibhag','vibhagid',$ rowdata-> vibhagid,''); $ bank = getRecordbyId('bank','bankid',$ rowdata-> ; bankid,''); $ dues = getRecordbyId('baltypes','typeid',$ rowdata-> rcbaltype,''); $ tehsil = getRecordbyId('tehsil','tehsilid',$ rowdata-> tehsil,''); $ nt = getRecordbyId('admin','admin_id',$ rowdata-> ntid,' '); $ amin = getRecordbyId('admin','admin_id',$ rowdata-> aminid,' ); $ myArr = array($ i,$ rowdata-> rc_no,$ rowdata-> manualrc,$ rowdata-> rc_name,$ bank- > bankname,$ rowdata-> amount,$ dues-> baltypename); $ excel-> writeLine($ myArr); $ i ++; b $ b } } $ fileName =AmountWise。$ dt。'。xls'; ?> < img src =images / preview.pngalt =/>I WANT TO FETCH THE DATA FROM DATABASE AND EXPORT TO EXCEL FILE. I DATA WILL COME CORECTLY BUT DIDNOT EXPORT TO EXCEL FILE...... JUST THE HEADING IS ONLY SHOW NOT THE DATA........BELOW IS MY CODE. PLEASE CORRECT THE CODE OR TELL HOW TO DO ITerror_reporting (E_ALL ^ E_NOTICE);require_once("excelwriter.class.php");$dt = date("d.m.Y");$fileName = "AmountWise ".$dt;$excel=new ExcelWriter("$fileName.xls");if($excel==false)echo $excel->error;$excel->writeLine($myArr);$myArr=array("Sr. No.","Net ID","R.C.","Defaulter Ka Naam","Bank/Vibhag Name","Rashi","Duestype");$excel->writeLine($myArr);if($_POST['amountfrom']!='' && $_POST['amountto']!='' && $tehsil==0){echo $sqlentry12 = "select * from rcentry where amount BETWEEN ".$_POST['amountto']." AND ".$_POST['amountfrom']."";}else if($_POST['amountfrom']!='' && $_POST['amountto']!='' && $tehsil!=0){echo $sqlentry12 = "select * from rcentry where tehsil='".$tehsil."' and amount BETWEEN ".$_POST['amountto']." AND ".$_POST['amountfrom']."";} $query12 =$db->query($sqlentry12); if(query12!=false){ $k=1; $i = 0;while($rowdata = $db->fetchObject()){$bgcolor = getBgColor($i++);$vibhag = getRecordbyId('vibhag', 'vibhagid', $rowdata->vibhagid, '');$bank = getRecordbyId('bank', 'bankid', $rowdata->bankid, ''); $dues = getRecordbyId('baltypes', 'typeid', $rowdata->rcbaltype, ''); $tehsil = getRecordbyId('tehsil', 'tehsilid', $rowdata->tehsil, ''); $nt = getRecordbyId('admin', 'admin_id', $rowdata->ntid, ''); $amin = getRecordbyId('admin', 'admin_id', $rowdata->aminid, '');$myArr=array($i, $rowdata->rc_no, $rowdata->manualrc, $rowdata->rc_name, $bank->bankname,$rowdata->amount,$dues->baltypename);$excel->writeLine($myArr);$i++;}}$fileName = "AmountWise ".$dt.'.xls';?><img src="images/preview.png" alt="" />推荐答案 dt = date(dmY);dt = date("d.m.Y"); fileName =AmountWise。fileName = "AmountWise ". dt;dt; 这篇关于数据没有从数据库导出到excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 21:18