A. php 如何將查詢結果導出到Excel中
如果是oracle
sql
developer的話,在查詢結果哪兒,用右鍵,可以導出成excel的。
如果用pl/sql
developer、toad之類的,也可以將查詢結果導出成excel
pl/sql
developer還可以直接查詢結果,到excel中粘貼。
如果用navicat
for
oracle,可以使用導出的方法。
B. php怎麼導出大量數據的Excel
php導出大量數據Excel的具體操作步驟如下:
C. PHP如何把資料庫導出EXCEL表格
< ?php function getmicrotime(){ list($usec, $sec) = explode(」 「,microtime()); return ((float)$usec + (float)$sec); } ?> < ?php $time_start = getmicrotime(); include(」db.inc.php」);//連接資料庫 $db=new testcsv; ?> < ?php $handle = fopen (」test.csv」,」r」); $sql=」insert into scores(idcard,names ,num,sex,nation,score) values(』」; while ($data = fgetcsv ($handle, 1000, 「,」)) { $num = count ($data); for ($c=0; $c < $num; $c++) { if($c==$num-1){$sql=$sql.$data[$c].」『)」;break;} $sql=$sql.$data[$c].」『,』」; } print 「< br>」; echo $sql.」< br>」; $db->query($sql); echo 「SQL語句執行成功!< br>」; $sql=」insert into scores(idcard,names ,num,sex,nation,score) values(』」; } fclose ($handle); $time_end = getmicrotime(); $time = $time_end – $time_start; echo 「程序執行時間:」.$time.」秒」; ?> 具體請參考:php新手入門網 http://www.phpnewer.com/index.php/Ymgx/detail/id/41
D. php怎麼導出大量數據的Excel
簡介:可以利用工具軟體導出成Excel文件
工具原料:Apache+php+mysql網站運行環境,phpMyAdmin v4.6.2
1、下載phpMyAdmin v4.6.2軟體後解壓放在網站根目錄
2、用root用戶和密碼登入phpMyAdmin,在左邊欄點擊要導出的資料庫,然後點擊要導出的數據表,最後點擊導出如圖所示。
5、最後點擊執行按鈕,OK.
E. php 怎麼把數據導出到excel表格
php 把數據導出到excel表格有多種方法,比如使用 phpExcel 等,以下代碼是直接通過 header 生成 excel 文件的代碼示例:
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=xls_region.xls");
$cfg_dbhost='localhost';
$cfg_dbname='testdb';
$cfg_dbuser='root';
$cfg_dbpwd='root';
$cfg_db_language='utf8';
//END配置
//鏈接資料庫
$link=mysql_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd);
mysql_select_db($cfg_dbname);
//選擇編碼
mysql_query("setnames".$cfg_db_language);
//users表
$sql="descusers";
$res=mysql_query($sql);
echo"<table><tr>";
//導出表頭(也就是表中擁有的欄位)
while($row=mysql_fetch_array($res)){
$t_field[]=$row['Field'];//Field中的F要大寫,否則沒有結果
echo"<th>".$row['Field']."</th>";
}
echo"</tr>";
//導出100條數據
$sql="select*fromuserslimit100";
$res=mysql_query($sql);
while($row=mysql_fetch_array($res)){
echo"<tr>";
foreach($t_fieldas$f_key){
echo"<td>".$row[$f_key]."</td>";
}
echo"</tr>";
}
echo"</table>";
?>
F. php 把資料庫中的數據 輸出到 Excel
有個excel class,直接用就可以了。
G. php搜索結果導出excel
可以循環
$objPHPExcel->setActiveSheetIndex(0);
for($a='A',$b=1;$b<=100;$b++){
$objPHPExcel->setCellValue($a.$b, 'Hello');
}
H. PHP如何將查詢出來的數據導出成excel表格(最好做一個按鈕)
講的復雜了啊!
你先在一個完整版的PHPExcel之後解壓,在「Examples」目錄下會找到一大堆例子,根據你的要求這個「01simple-download-xlsx.php」文件就可以了!
註:你先保持「01simple-download-xlsx.php」文件所在的目錄位置不要變,測試好了,再改變名,移到別的地方,地方變了的話,文件里的 「require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';」的所在位置也要變!
我們要改動代碼很少,如下:
// Add some data
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
直接用的我的替換
$objPHPExcel->setActiveSheetIndex(0)//這個就是現實導出的表第一行,有幾列是根據你的那張表有幾列!
->setCellValue('A1', '單號')
->setCellValue('B1', '標題')
->setCellValue('C1', '內容')
->setCellValue('D1', '序列')
->setCellValue('E1', '數字');
//下面實現的就是建立資料庫連接,直接到表,你的連接資料庫、表、欄位應該與我的不一樣,你可以參考
$conn=@mysql_connect("localhost","root","root") or die("資料庫伺服器連接錯誤".mysql_error());//連接mysql資料庫
mysql_select_db("temp",$conn) or die("資料庫訪問錯誤".mysql_error());//資料庫
mysql_query("set character set gb2312");
mysql_query("set names gb2312");
$sqlgroups="select * from test ";//查詢這一張表的條件
$resultgroups=mysql_query($sqlgroups);
$numrows=mysql_num_rows($resultgroups);
if ($numrows>0)
{
$count=1;
while($data=mysql_fetch_array($resultgroups))
{
$count+=1;
$l1="A"."$count";
$l2="B"."$count";
$l3="C"."$count";
$l4="D"."$count";
$l5="E"."$count";
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($l1, $data['id'])//這就是你要導出表的欄位、與對應的名稱
->setCellValue($l2, $data['title'])
->setCellValue($l3, $data['content'])
->setCellValue($l4, $data['sn'])
->setCellValue($l5, $data['num']);
}
}
I. php 把資料庫中的數據 輸出到 Excel
方法一:
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=test_data.xls");
$tx='表頭';
echo
$tx."\n\n";
//輸出內容如下:
echo
"姓名"."\t";
echo
"年齡"."\t";
echo
"學歷"."\t";
echo
"\n";
echo
"張三"."\t";
echo
"25"."\t";
echo
"本科"."\t";
?>
方法二:
PHPEXCEL
類庫,功能強大,支持win
Excel2003
,Win
Excel2007.下載類庫,里邊有例子