请问:数据库中的多级主从表导出到EXCEL怎么存储,并且可以再导入到数据库中!
谢谢,等待!!!!
谢谢,等待!!!!
解决方案 »
- 调用函数出错
- DataHint V1.1 Beta 控件发布;拼音过滤类似 LookupComboBox
- 看到有memo中显示图片,是怎么回事呢?
- 关于TCP传文件的一个疑惑?
- 请问大家一 个多线程的问题,(同步或者锁定)
- 请教字符串查找问题,谢谢回复
- Delphi 数据库程序界面设计问题
- 为什么用dephi自带的数据库database Desktop建立的表,在程序中做查询时经常查不出数据来
- 有哪位高手知道哪里可以找到WMA的文件格式!只需要读取各个版本的WMA的信息就可以了!
- TAdvStringgrid 是什么组件?
- 这个调用过程很复杂,且很好!请高手分析
- delphi 7中找不到delphi6中的fastnet面板
SysUtils, Windows, Messages, Classes, Graphics,
Controls, Forms, DBCtrls, StdCtrls, DBTables,
ExtCtrls, Mask, Db, Dialogs, Excel97, Word97,
OleServer;type
TFormOff = class(TForm)
DBEdit3: TDBEdit;
Label3: TLabel;
Label2: TLabel;
DBEdit2: TDBEdit;
DBEdit1: TDBEdit;
Label1: TLabel;
DBNavigator1: TDBNavigator;
Table1: TTable;
DataSource1: TDataSource;
BtnExcel: TButton;
SaveDialog1: TSaveDialog;
ExcelApplication1: TExcelApplication;
procedure BtnExcelClick(Sender: TObject);
end;var
FormOff: TFormOff;implementation{$R *.DFM}uses
ComObj, ActiveX;
procedure TFormOff.BtnExcelClick(Sender: TObject);
var
RangeE: Excel97.Range;
I, Row: Integer;
Book: TBookStr;
begin
// create and show
ExcelApplication1.Visible [0] := True;
ExcelApplication1.Workbooks.Add (NULL, 0);
// fill is the first row with field titles
RangeE := ExcelApplication1.ActiveCell;
for I := 0 to Table1.Fields.Count - 1 do
begin
RangeE.Value := Table1.Fields [I].DisplayLabel;
RangeE := RangeE.Next;
end;
// add field data in following rows
Table1.DisableControls;
try
Book := Table1.Book;
try
Table1.First;
Row := 2;
while not Table1.EOF do
begin
RangeE := ExcelApplication1.Range ['A' + IntToStr (Row),
'A' + IntToStr (Row)];
for I := 0 to Table1.Fields.Count - 1 do
begin
RangeE.Value := Table1.Fields [I].AsString;
RangeE := RangeE.Next;
end;
Table1.Next;
Inc (Row);
end;
finally
Table1.Book := Book;
end;
finally
Table1.EnableControls;
end;
RangeE := ExcelApplication1.Range ['A1', 'E' + IntToStr (Row - 1)];
RangeE.AutoFormat (3, NULL, NULL, NULL, NULL, NULL, NULL);
end;initialization
CoInitialize (nil);
end.
这个帖子看看,这几天关于EXCEL的问题很多。