使用phpexcel插件。
<?php/**
* erport
* 导出excel
*/
$dir = dirname ( __FILE__ )
require $dir . '/Class/db.class.php'
require $dir . '/PHPExcel/PHPExcel.php'
$dbObj = new db ()
$phpexcelObj = new PHPExcel ()
for($i = 1 $i <= 3 $i ++) {
$what = "*"
$condition = "student where grade = " . $i . " ORDER BY score DESC"
$res = $dbObj->mySelect ( $what, $condition )
if ($i > 1) {
$phpexcelObj->createSheet ()
}
$phpexcelObj->setActiveSheetIndex ( $i - 1 )
$sheetObj = $phpexcelObj->getActiveSheet ( $i )
$sheetObj->setTitle ( $i . "年级" )
$sheetObj->setCellValue ( 'A1', 'name' )->setCellValue ( 'B1', 'score' )->setCellValue ( 'C1', 'class' )
$j = 2
foreach ( $res as $key => $val ) {
$sheetObj->setCellValue ( 'A' . $j, $res [$key] ['name'] )->setCellValue ( 'B' . $j, $res [$key] ['score'] )->setCellValue ( 'C' . $j, $res [$key] ['class'] )
$j ++
}
}
$phpexcelObj->setActiveSheetIndex ( 1 )
$writerObj = PHPExcel_IOFactory::createWriter ( $phpexcelObj, 'Excel5' )
$writerObj->save ( $dir . '/Excels/scores.xls' )
1.完整的导出整个数据库表结构即dmp文件方法:Tools-->Export Tables ,选择Oracle Export 默认选项即可,在Output file选择一个输出目标
点击Export,即可导出表结构
2.导出表中数据:
Tools-->Export Tables :选择SQL Inserts 遇到大字段(clob,blob)会出问题导不出来,在此可以
选择需要导出的表,在Output file中选择导出的目标,点击Export即可导出,在此有几个选项
可以去掉所有的可选项直接导出
3.导出数据库中所有的或是所选表的数据库建表脚本:
Tools-->Export User Objects去掉下面三个include *可选项,选择Single file)在Output file
中选择输出目标,点击Export即可
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)