怎样将SQL explorer 中看到的数据导成EXCLE格式? 怎样将SQL explorer 中看到的数据导成EXCLE格式?不够再加~~~~~!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你什么数据库?1:如果是sql server 你用‘查询分析器’它里面有另存,可以存我excel文件2:如果是其他数据库,你还是用delphi编写个程序吧,非常简单。() 我是paradox的数据库 后缀为.db 也可以用sql的dts到出或者用程序控制建立一个odbc数据源为qq比如导出orders表到aa.xls'unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, StdCtrls, ExcelXP, OleServer;type TForm1 = class(TForm) Button1: TButton; ExcelApp: TExcelApplication; ExcelQueryTable: TExcelQueryTable; ExcelBook: TExcelWorkbook; procedure Button1Click(Sender: TObject); private { Private declarations } function ToExcelFile(var Filename,SheetName,WIndowCaption:OleVariant;SqlStr:String):Boolean; public { Public declarations } end;var Form1: TForm1;implementation uses ComObj;{$R *.dfm}function TForm1.ToExcelFile(var Filename,SheetName,WindowCaption:OleVariant;SqlStr:String):Boolean;varNewTemplate,ItemIndex:olevariant;CurSheet:_WorkSheet;connectStr:olevariant;beginNewTemplate:=emptyParam;trytryExcelApp.Connect;exceptMessageDlg('您可能没有安装EXCEL', mtError, [mbOk], 0);Abort;end;ExcelApp.visible[0]:=TRUE;ExcelApp.Caption:=WindowCaption;ExcelApp.Workbooks.Add(Newtemplate,0);ExcelBook.ConnectTo(ExcelApp.workBooks.Item[1]);ExcelBook.Title[0]:=WIndowCaption;ExcelBook.Activate;CurSheet:=ExcelBook.Sheets[1] as _worksheet;CurSheet.Name:=SheetName;connectstr := 'ODBC;DSN=qq;';CurSheet.QueryTables.Add(connectstr,CurSheet.range['a3','e3'],SqlStr);ExcelQueryTable.ConnectTo(CurSheet.QueryTables.Item(1));ExcelQueryTable.Refresh;excepton E: Exception dobeginItemIndex:=FALSE;ExcelBook.Close(ItemIndex);ExcelApp.Disconnect;ExcelApp.Quit;Application.MessageBox('数据输出到EXCEL过程出错,请检查EXCEL版本是否一致','警告',mb_ok);exit;end;end;ExcelQueryTable.Disconnect;ExcelBook.Disconnect;ExcelApp.Disconnect;Result:=TRUE;end;procedure TForm1.Button1Click(Sender: TObject);var XlsApp,XlsSheet,WndCaption:OleVariant;begin XlsApp:=OleVariant('c:\aa.xls'); XlsSheet:=OleVariant('a'); WndCaption:=OleVariant('test'); ToExcelFile(XlsApp,XlsSheet,WndCaption,'select * from orders');end;end. EXEC master..xp_cmdshell 'bcp 数据库服务器名.dbo.数据库名 out c:\temp1.xls -c -q -S"表名" -U"sa" -P"密码"' 关于文本文件操作问题,求解! 打砖块游戏设计 求教 tidtcpserver如何用Readbuff()来接收数据? 文科生在学习中的一点疑问,请大家不吝赐教 关于FTP文件上传问题,高手帮帮忙! [惯水]请用四个字概括你的长相,最好不要重复。 散分恭喜老乡陈艳青在雅典奥运会举重女子58公斤级比赛中,以237.5公斤获得金牌。 请教几个窗口扩展风格常量的含义。 printdialog怎么用呀? DateTimePicker以及DateTimetoStr问题,分都给你了 p2p的问题!
2:如果是其他数据库,你还是用delphi编写个程序吧,非常简单。()
或者用程序控制
建立一个odbc数据源为qq比如导出orders表到aa.xls'
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExcelXP, OleServer;type
TForm1 = class(TForm)
Button1: TButton;
ExcelApp: TExcelApplication;
ExcelQueryTable: TExcelQueryTable;
ExcelBook: TExcelWorkbook;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function ToExcelFile(var Filename,SheetName,WIndowCaption:OleVariant;SqlStr:String):Boolean;
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses ComObj;
{$R *.dfm}function TForm1.ToExcelFile(var Filename,SheetName,WindowCaption:OleVariant;SqlStr:String):Boolean;
var
NewTemplate,ItemIndex:olevariant;
CurSheet:_WorkSheet;
connectStr:olevariant;
begin
NewTemplate:=emptyParam;
try
try
ExcelApp.Connect;
except
MessageDlg('您可能没有安装EXCEL', mtError, [mbOk], 0);
Abort;
end;
ExcelApp.visible[0]:=TRUE;
ExcelApp.Caption:=WindowCaption;
ExcelApp.Workbooks.Add(Newtemplate,0);
ExcelBook.ConnectTo(ExcelApp.workBooks.Item[1]);
ExcelBook.Title[0]:=WIndowCaption;
ExcelBook.Activate;
CurSheet:=ExcelBook.Sheets[1] as _worksheet;
CurSheet.Name:=SheetName;
connectstr := 'ODBC;DSN=qq;';
CurSheet.QueryTables.Add(connectstr,CurSheet.range['a3','e3'],SqlStr);
ExcelQueryTable.ConnectTo(CurSheet.QueryTables.Item(1));
ExcelQueryTable.Refresh;
except
on E: Exception do
begin
ItemIndex:=FALSE;
ExcelBook.Close(ItemIndex);
ExcelApp.Disconnect;
ExcelApp.Quit;
Application.MessageBox('数据输出到EXCEL过程出错,请检查EXCEL版本是否一致','警告',mb_ok);
exit;
end;
end;
ExcelQueryTable.Disconnect;
ExcelBook.Disconnect;
ExcelApp.Disconnect;
Result:=TRUE;
end;
procedure TForm1.Button1Click(Sender: TObject);
var XlsApp,XlsSheet,WndCaption:OleVariant;
begin
XlsApp:=OleVariant('c:\aa.xls');
XlsSheet:=OleVariant('a');
WndCaption:=OleVariant('test');
ToExcelFile(XlsApp,XlsSheet,WndCaption,'select * from orders');end;end.