📄 unit1.pas
字号:
query1.Open;
sky14:=0;
sky21:=0;
sky25:=0;
sky29:=0;
sky34:=0;
sky38:=0;
CHANG:=0;
TCL:=0;
HAIER:=0;
KONKA:=0;
X01:=0;
while not query1.EOF do
begin
sky14:=sky14+query1.FieldByName('SKY14').value;
sky21:=sky21+query1.FieldByName('sky21').value;
sky25:=sky25+query1.FieldByName('sky25').value;
sky29:=sky29+query1.FieldByName('sky29').value;
sky34:=sky34+query1.FieldByName('SKY34').value;
sky38:=sky38+query1.FieldByName('SKY38').value;
CHANG:=CHANG+query1.FieldByName('CHANG').value;
KONKA:=KONKA+query1.FieldByName('KAKON').value;
TCL:=TCL+query1.FieldByName('TCL').value;
HAIER:=HAIER+query1.FieldByName('HAIER').value;
X01:=X01+query1.FieldByName('X01').value;
query1.Next;
end;
if not query1.IsEmpty then
begin
try
MsExcel:=CreateOleObject('Excel.Application.8');
MsExcelWorkBook:=MsExcel.WorkBooks.Add;
MsExcelWorkSheet:=MsExcel.WorkSheets.Add;
except
MessageDlg('启动Excel 97出现异常!!请检查你的机器内是否安装OFFICE97?',mtWarning,[mbOK],0);
exit;
end;
MsExcel.Visible:=True;
{+========================================+}
MsExcelWorkSheet.Range['F1'].Value:=GB2Big.GBtoBIG5('创维公司各办事处日销量专柜零售量(台数)统计表') ;
MsExcelWorkSheet.Range['a3'].Value:=GB2Big.GBtoBIG5('统计日期: ')+datetostr(date) ;
MsExcelWorkSheet.Range['l3'].Value:=GB2Big.GBtoBIG5('创维销售总部市场部');
MsExcelWorkSheet.Range['A4'].Value:=GB2Big.GBtoBIG5('名次') ;
MsExcelWorkSheet.Range['b4'].Value:=GB2Big.GBtoBIG5('分部') ;
MsExcelWorkSheet.Range['c4'].Value:=GB2Big.GBtoBIG5('创维14寸');
MsExcelWorkSheet.Range['d4'].Value:=GB2Big.GBtoBIG5('创维21');
MsExcelWorkSheet.Range['e4'].Value:=GB2Big.GBtoBIG5('创维25寸') ;
MsExcelWorkSheet.Range['f4'].Value:=GB2Big.GBtoBIG5('创维29寸') ;
MsExcelWorkSheet.Range['g4'].Value:=GB2Big.GBtoBIG5('创维34寸') ;
MsExcelWorkSheet.Range['h4'].Value:=GB2Big.GBtoBIG5('创维38寸') ;
MsExcelWorkSheet.Range['i4'].Value:=GB2Big.GBtoBIG5('创维合计' );
MsExcelWorkSheet.Range['j4'].Value:=GB2Big.GBtoBIG5('长虹合计') ;
MsExcelWorkSheet.Range['k4'].Value:=GB2Big.GBtoBIG5('康佳合计') ;
MsExcelWorkSheet.Range['l4'].Value:=GB2Big.GBtoBIG5('TCL合计') ;
MsExcelWorkSheet.Range['m4'].Value:=GB2Big.GBtoBIG5('海尔合计' );
QUERY1.First;
J:=0;
WHILE NOT QUERY1.EOF DO
begin
J:=j+1;
for i:=0 to query1.FieldCount-1 do
begin
if i=0 then C:='A';
if i=1 then C:='B';
if i=2 then C:='C';
if i=3 then C:='D';
if i=4 then C:='E';
if i=5 then C:='F';
if i=6 then C:='G';
if i=7 then C:='H';
if i=8 then C:='I';
if i=9 then C:='J';
if i=10 then C:='K';
if i=11 then C:='L';
if i=12 then C:='M';
if i=13 then C:='N';
if i=14 then C:='O';
if i=15 then C:='P';
if i=16 then C:='K';
if i=17 then C:='R';
if i=18 then C:='S';
if i=19 then C:='T';
if i=20 then C:='U';
if i=21 then C:='V';
if i=22 then C:='W';
if i=23 then C:='X';
if i=24 then C:='Y';
if i=25 then C:='Z';
if i=26 then C:='AA';
if i=27 then C:='AB';
if i=28 then C:='AC';
if i=29 then C:='AD';
if i=30 then C:='AE';
if i=31 then C:='AF';
if i=32 then C:='AG';
if i=33 then C:='AH';
if i=34 then C:='AI';
if i=35 then C:='AJ';
if i=36 then C:='AK';
if i=37 then C:='AL';
if i=38 then C:='AM';
if i=39 then C:='AN';
if i=40 then C:='AO';
if i=41 then C:='AP';
if i=42 then C:='AK';
if i=43 then C:='AR';
if i=44 then C:='AS';
if i=45 then C:='AT';
if i=46 then C:='AU';
if i=47 then C:='AV';
if i=48 then C:='AW';
if i=49 then C:='AX';
if i=50 then C:='AY';
if i=51 then C:='AZ';
if (i<>1) then begin
if (i<>0) then begin
MsExcelWorkSheet.Range[C+IntToStr(J+4)].Value:=QUERY1.Fields[i].AsString ;
end else
begin
MsExcelWorkSheet.Range[C+IntToStr(J+4)].Value:=GB2Big.GBtoBIG5(QUERY1.Fields[i].AsString) ;
end;
end else
begin
MsExcelWorkSheet.Range[C+IntToStr(J+4)].Value:=GB2Big.GBtoBIG5(QUERY1.Fields[i].AsString) ;
end;
end;
QUERY1.Next;
end;
j:=j+4;
MsExcelWorkSheet.Range['A'+IntToStr(J+1)].Value:=GB2Big.GBtoBIG5('总计:');
MsExcelWorkSheet.Range['b'+IntToStr(J+1)].Value:='';
MsExcelWorkSheet.Range['c'+IntToStr(J+1)].Value:=inttostr(sky14);
MsExcelWorkSheet.Range['d'+IntToStr(J+1)].Value:=inttostr(sky21);
MsExcelWorkSheet.Range['e'+IntToStr(J+1)].Value:=inttostr(sky25);
MsExcelWorkSheet.Range['f'+IntToStr(J+1)].Value:=inttostr(sky29);
MsExcelWorkSheet.Range['g'+IntToStr(J+1)].Value:=inttostr(sky34);
MsExcelWorkSheet.Range['h'+IntToStr(J+1)].Value:=inttostr(sky38);
MsExcelWorkSheet.Range['i'+IntToStr(J+1)].Value:=inttostr(X01);
MsExcelWorkSheet.Range['j'+IntToStr(J+1)].Value:=inttostr(CHANG);
MsExcelWorkSheet.Range['k'+IntToStr(J+1)].Value:=inttostr(KONKA);
MsExcelWorkSheet.Range['l'+IntToStr(J+1)].Value:=inttostr(TCL);
MsExcelWorkSheet.Range['m'+IntToStr(J+1)].Value:=inttostr(HAIER);
{+================================================+}
try
deletefile(GB2Big.GBtoBIG5(DirectoryListBox1.Directory+'\办事处日销量专柜统计BIG5码('+datetostr(date)+').XLS'));
MsExcelWorkSheet.SaveAs(GB2Big.GBtoBIG5(DirectoryListBox1.Directory+'\办事处日销量专柜统计BIG5码('+datetostr(date)+').XLS'));
except
MessageDlg('无法保存 '+GB2Big.GBtoBIG5(DirectoryListBox1.Directory+'\办事处日销量专柜统计BIG5码('+datetostr(date)+').XLS'),mtInformation,[mbOK],0);
end;
end;
end;
procedure TForm1.CHJ;
var
i:integer;
begin
{+=====读取信息====================}
memo1.Lines.Clear;
memo2.Lines.Clear;
memo3.Lines.Clear;
for i:=0 to Query1.FieldCount-1 do
begin
memo2.Lines.Add(Query1.Fields[i].fieldname) ;
if (Query1.FieldDefs[i].datatype=ftstring) or (Query1.FieldDefs[i].datatype=ftfloat) or (Query1.FieldDefs[i].datatype=ftdate) or (Query1.FieldDefs[i].datatype=ftsmallint) or (Query1.FieldDefs[i].datatype=ftword) or (Query1.FieldDefs[i].datatype=ftautoinc) or (Query1.FieldDefs[i].datatype=ftinteger) or (Query1.FieldDefs[i].datatype=ftbcd) or (Query1.FieldDefs[i].datatype=ftCurrency) or(Query1.FieldDefs[i].datatype=ftdatetime) or (Query1.FieldDefs[i].datatype=ftmemo) or (Query1.FieldDefs[i].datatype=fttime) or (Query1.FieldDefs[i].datatype=ftblob) then
begin
if (Query1.FieldDefs[i].datatype=ftdate) then
begin
memo3.Lines.Add('ftdate');
end;
if (Query1.FieldDefs[i].datatype=ftdatetime) then
begin
memo3.Lines.Add('ftdate');
end;
if (Query1.FieldDefs[i].datatype=ftcurrency) then
begin
memo3.Lines.Add('ftcurrency');
end;
if (Query1.FieldDefs[i].datatype=ftmemo) then
begin
memo3.Lines.Add('ftmemo');
end;
if (Query1.FieldDefs[i].datatype=ftbcd) then
begin
memo3.Lines.Add('ftbcd');
end;
if (Query1.FieldDefs[i].datatype=fttime) then
begin
memo3.Lines.Add('fttime');
end;
if (Query1.FieldDefs[i].datatype=ftautoinc) then
begin
memo3.Lines.Add('ftautoinc');
end;
if (Query1.FieldDefs[i].datatype=ftblob) then
begin
memo3.Lines.Add('ftblob');
end;
if (Query1.FieldDefs[i].datatype=ftstring) then
begin
memo3.Lines.Add('ftstring');
end;
if (Query1.FieldDefs[i].datatype=ftword) then
begin
memo3.Lines.Add('ftword');
end;
if (Query1.FieldDefs[i].datatype=ftsmallint) then
begin
memo3.Lines.Add('ftsmallint');
end;
if (Query1.FieldDefs[i].datatype=ftinteger) then
begin
memo3.Lines.Add('ftinteger');
end;
if (Query1.FieldDefs[i].datatype=ftfloat) then
begin
memo3.Lines.Add('ftfloat');
end;
if (Query1.FieldDefs[i].datatype=ftBoolean) then
begin
memo3.Lines.Add('ftboolean');
end;
end
else
begin
memo3.Lines.Add('OTHER');
end;
memo1.Lines.Add(inttostr(Query1.Fields[i].displaywidth));
end;
chdir(form1.DirectoryListBox1.Directory);
memo2.Lines.SaveToFile('dat\fieldname.dat');
memo3.Lines.SaveToFile('dat\fieldtype.dat');
memo1.Lines.SaveToFile('dat\fieldsize.dat');
{===============节束====================}
end;
procedure Tform1.CHJO;
var i:integer;
p: word;
begin
Memo1.Lines.Clear;
Memo2.Lines.Clear;
Memo3.Lines.clear;
chdir(form1.DirectoryListBox1.Directory);
Memo2.Lines.LoadFromFile('dat\fieldname.dat');
Memo3.Lines.LoadFromFile('dat\fieldtype.dat');
Memo1.Lines.LoadFromFile('dat\fieldsize.dat');
ClientDataSet1.FieldDefs.Clear;
for i:=0 to Memo2.Lines.Count-1 do
begin
if Memo3.Lines[i]='ftsmallint' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftsmallint,0,false);
end;
if Memo3.Lines[i]='ftdate' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftdate,0,false);
end;
if Memo3.Lines[i]='ftword' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftword,0,false);
end;
if Memo3.Lines[i]='ftinteger' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftinteger,0,false);
end;
if Memo3.Lines[i]='ftfloat' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftfloat,0,false);
end;
if Memo3.Lines[i]='ftboolean' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftboolean,0,false);
end;
if Memo3.Lines[i]='fttime' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],fttime,0,false);
end;
if Memo3.Lines[i]='ftautoinc' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftautoinc,0,false);
end;
if Memo3.Lines[i]='ftcurrency' then
begin
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftcurrency,0,false);
end;
if Memo3.Lines[i]='ftmemo' then
begin
p:= word(strtoint(memo1.Lines[i]));
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftmemo,p,false);
end;
if Memo3.Lines[i]='ftstring' then
begin
p:= word(strtoint(memo1.Lines[i]));
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftstring,p,false);
end;
if Memo3.Lines[i]='ftbcd' then
begin
p:= word(strtoint(memo1.Lines[i]));
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftbcd,p,false);
end;
if Memo3.Lines[i]='ftblob' then
begin
p:= word(strtoint(memo1.Lines[i]));
ClientDataSet1.FieldDefs.Add(Memo2.Lines[i],ftblob,p,false);
end;
end;
ClientDataSet1.Close;
ClientDataSet1.CreateTable;
ClientDataSet1.Open;
ClientDataSet1.close;
end;
procedure Tform1.CHJI;
begin
ClientDataSet1.Open;
BatchMove1.Source:=query1;
BatchMove1.Destination:=ClientDataSet1;
BatchMove1.Mode:=batAppend;
BatchMove1.Execute;
ClientDataSet1.Close;
end;
{=============数据库模块结束===========================}
procedure TForm1.FormCreate(Sender: TObject);
begin
forcedirectories(form1.DirectoryListBox1.Directory+'\dat\');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -