如何将oracle中的表导入到excel中?
我想将oracle中的表导出到存成excel文件,请问该如何操作? 问题点数:0、回复次数:7Top
1 楼hyee(小狗旺财)回复于 2004-12-02 00:23:49 得分 0
用plsql developerTop
2 楼baojianjun(包子)回复于 2004-12-02 08:20:10 得分 0
用工具或從界面上導出Top
3 楼GerryYang(轻尘)回复于 2004-12-02 08:22:38 得分 0
有很多方法.
1. 先用spool 表数据导出.
然后打开excel,数据/导入外部数据即可.
2. 直接打开excel,数据/导入外部数据,选择你的数据源,然后选择你要的表就可以了.Top
4 楼phant0m(YO-YO)回复于 2004-12-02 08:40:24 得分 0
plsql developer,右键--export results--csv.fileTop
5 楼linysh(我爱小朋友)回复于 2004-12-02 09:14:41 得分 0
使用Excel里面的数据导入,直接通过 ODBC ,选择所需的表,即可直接导入。Top
6 楼ATGC(花开蝶舞,木秀鸟栖)回复于 2004-12-02 09:30:25 得分 0
方法多种多样,可以利用工具,也可以写程序
俺写一Perl程序,但最多只能select 255列,因为Excel一个sheet最多只有255列
实施步骤
1、先到www.activeperl.com去下载一个activeperl,免费的
2、安装perl
3、到\Perl\bin下面执行 ppm
4、出现PPM提示符如下
D:\Perl\bin>PPM
PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM>
5、在PPM提示符下执行如下命令,安装数据库连接模块DBI,DBD
PPM>install dbi
PPM>install dbd-oracle
6、执行下面的perl程序即可,其中用户名和密码,以及连接字符串自己改改
再命令窗口直接键入如下命令格式,该程序无需编译,祝你好运
table2xls.pl
7、该程序不支持RAW,LONG和LOB类型的字段
table2xls.pl
#!/usr/bin/perl -w
#function: select records from table and print to Excel file
#author: ATGC
#version: 1.0
#date of compilation September 6,2004
#you can change the following parameters
my $conn_str = '连接名';
my $user = 'user';
my $pass = 'password';
my $excel_file = 'e:\output.xls';
my $sql = "select * from table";
use strict;
use DBI;
use Win32::OLE;
my($dbh,$sth,$row,$col,@field,$ele,$c_times,$residual,$cols,$cell_end);
unlink $excel_file if (-e $excel_file);
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->add;
my $Sheet = $Book->Worksheets(1);
my @array_cols=("","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$dbh = DBI->connect("DBI:Oracle:$conn_str",$user,$pass);
$sth = $dbh->prepare($sql);
$sth->execute();
$row=1;
$cols=0;
if (@field = $sth->fetchrow)
{
$cols=scalar(@field);
$c_times=int($cols/26);
$residual=$cols%26;
if ($cols<27)
{
$cell_end = $array_cols[$cols];
}
else
{
if ($residual == 0)
{
$cell_end = $array_cols[$c_times-1]."Z";
}
else
{
$cell_end = $array_cols[$c_times].$array_cols[$residual];
}
}
$Sheet->Range("A1:$cell_end$row")->{Value} = [@field];
while(@field = $sth->fetchrow)
{
$row++;
$Sheet->Range("A$row:$cell_end$row")->{Value} = [@field];
}
$sth->finish();
$dbh->disconnect();
$Book->SaveAs($excel_file);
}
undef($Sheet);
undef($Book);
undef($Excel);
Top
7 楼xt9812037(大脸猫)回复于 2004-12-02 22:36:53 得分 0
多谢多谢,我会一一试的!!Top




