📄 jgjtbbgs.pas
字号:
style:=0;
if toolbutton40.down then
style:=1;
if toolbutton41.down then
style:=4;
if toolbutton42.down then
style:=2;
if toolbutton44.down then
style:=style+8;
if toolbutton45.down then
style:=style+32;
if toolbutton46.down then
style:=style+16;
//设置对齐方式
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
for ni:=scol to ecol do
for nl:=srow to erow do
cell1.DoSetCellAlignment(ni,nl,style);
cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.ToolButton38Click(Sender: TObject);
{自动折行显示}
var
scol,srow,ecol,erow:olevariant;
style,ni,nl:integer;
begin
if toolbutton38.down then
style:=1
else
style:=0;
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
for ni:=scol to ecol do
for nl:=srow to erow do
cell1.DoSetCellTextStyle(ni,nl,style);
cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.ToolButton35Click(Sender: TObject);
{字体/字号/样式}
var
scol,srow,ecol,erow:olevariant;
fstyle,fsize,ni,nl:integer;
fname:string;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
fsize:=strtoint(combobox4.text);
fname:=combobox2.Text;
if (toolbutton35.Down) then //精
begin
if (toolbutton36.Down) then //斜
begin
if (toolbutton37.Down) then //下划
fstyle:=7
else //无下划
fstyle:=4;
end
else //非斜
begin
if (toolbutton37.Down) then //下划
fstyle:=5
else //无下划
fstyle:=1;
end;
end
else //非粗
begin
if (toolbutton36.Down) then //斜
begin
if (toolbutton37.Down) then //下划
fstyle:=6
else //无下划
fstyle:=2;
end
else //非斜
begin
if (toolbutton37.Down) then //下划
fstyle:=3
else //无下划
fstyle:=0;
end;
end;
for ni:=scol to ecol do
for nl:=srow to erow do
cell1.DoSetCellFont(ni,nl,fsize,fstyle,fname);
cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.ToolButton25Click(Sender: TObject);
{增加小数位}
begin
if dec_inc<5 then
dec_inc:=dec_inc+1;
toolbutton51.OnClick(self) ;
end;
procedure TFormJtBbGs.ToolButton26Click(Sender: TObject);
{减少小数位}
begin
if dec_inc>-1 then
dec_inc:=dec_inc-1;
toolbutton51.OnClick(self) ;
end;
procedure TFormJtBbGs.ToolButton51Click(Sender: TObject);
{设置数据格式}
var
c_commas,c_currency,ni,nl:integer;
c_percent:boolean;
scol,srow,ecol,erow:olevariant;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
if toolbutton49.Down then
c_currency:=1
else
c_currency:=-1;
if toolbutton50.Down then
c_percent:=true
else
c_percent:=false;
if toolbutton51.Down then
c_commas:=1
else
c_commas:=0;
for ni:=scol to ecol do
for nl:=srow to erow do
Cell1.DoSetCellNumberStyle(ni,nl,c_commas,
c_percent,dec_inc,c_currency,1,-1,false);
cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.N2Click(Sender: TObject);
{报表表尺寸}
var
bbs:tbbsize;
begin
bbs:=tbbsize.Create(Application);
cell_cols:=inttostr(cell1.Cols);
cell_rows:=inttostr(cell1.Rows);
if bbs.ShowModal = mrOk then
begin
Cell1.Rows:=strtoint(bbs.edit1.text);
Cell1.Cols:=strtoint(bbs.edit2.text);
end;
bbs.free;
Cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.N5Click(Sender: TObject);
{插入行}
var
row:integer;
BbIns:tbbstructIns;
begin
Row:=cell1.DoGetCurrentRow();
bbins:=tbbstructins.Create(Application);
bbins.caption:='插入行';
bbins.Label1.Caption :='插入行数';
if bbIns.ShowModal = mrOk then
cell1.DoInsertRow(row,strtoint(Bbins.edit1.Text));
bbins.free;
Cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.N9Click(Sender: TObject);
{插入列}
var
Col:integer;
BbIns:tbbstructIns;
begin
Col:=cell1.DoGetCurrentCol();
bbins:=tbbstructins.Create(Application);
bbins.caption:='插入列';
bbins.Label1.Caption :='插入列数';
if bbIns.ShowModal = mrOk then
cell1.DoInsertCol(Col,strtoint(Bbins.edit1.Text));
bbins.free;
Cell1.DoRedrawAll;
end;
procedure TFormJtBbGs.N7Click(Sender: TObject);
{追加行}
var
BbIns:tbbstructIns;
begin
bbins:=tbbstructins.Create(Application);
bbins.caption:='追加行';
bbins.Label1.Caption :='追加行数';
if bbIns.ShowModal = mrOk then
cell1.DoAppendRow(strtoint(Bbins.edit1.Text));
bbins.free;
Cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.N11Click(Sender: TObject);
{追加列}
var
BbIns:tbbstructIns;
begin
bbins:=tbbstructins.Create(Application);
bbins.caption:='追加列';
bbins.Label1.Caption :='追加列数';
if bbIns.ShowModal = mrOk then
cell1.DoAppendCol(strtoint(Bbins.edit1.Text));
bbins.free;
Cell1.DoRedrawAll;
end;
procedure TFormJtBbGs.N6Click(Sender: TObject);
var
BbDel:tbbstructDel;
scol,srow,ecol,erow:olevariant;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
bbdel:=tbbstructdel.Create(Application);
bbdel.Label1.Caption :='删除行';
bbdel.Edit1.text:=inttostr(srow+1);
bbdel.Edit2.text:=inttostr(erow+1);
if bbDel.ShowModal = mrOk then
cell1.DoDeleteRow(strtoint(bbdel.edit1.text)-1,
strtoint(bbdel.edit2.text)-strtoint(bbdel.edit1.text)+1);
bbdel.free;
Cell1.DoRedrawAll;
end;
procedure TFormJtBbGs.N10Click(Sender: TObject);
var
BbDel:tbbstructDel;
scol,srow,ecol,erow:olevariant;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
bbdel:=tbbstructdel.Create(Application);
bbdel.Label1.Caption :='删除列';
bbdel.Edit1.text:=inttostr(scol+1);
bbdel.Edit2.text:=inttostr(ecol+1);
if bbDel.ShowModal = mrOk then
cell1.DoDeleteCol(strtoint(bbdel.edit1.text)-1,
strtoint(bbdel.edit2.text)-strtoint(bbdel.edit1.text)+1);
bbdel.free;
Cell1.DoRedrawAll;
end;
procedure TFormJtBbGs.N8Click(Sender: TObject);
var
BbRC:tbbstructRC;
scol,srow,ecol,erow:olevariant;
RowHeight,RowH,ni:Integer;
RowHc:string;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
bbRC:=tbbstructRC.Create(Application);
bbRC.Label1.Caption :='行高';
bbRC.Caption:='行高';
Cell1.DoGetRowHeight(sRow,RowHeight);
RowHc:=IntToStr(RowHeight);
for ni:=srow+1 to erow do
begin
Cell1.DoGetRowHeight(ni,RowH);
if RowHeight<>RowH then
begin
RowHc:='';
Break;
end;
end;
BbRC.Edit1.Text :=RowHc;
if bbRc.ShowModal = mrOk then
if (bbrc.Edit1.text='') or (strtoint(bbrc.edit1.text)<=0) then
showmessage('行高设置错误!')
else
Cell1.DoSetRowHeightEx(srow,erow,strtoint(bbrc.Edit1.Text),bbrc.combobox1.itemindex);
Cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.N12Click(Sender: TObject);
var
BbRC:tbbstructRC;
scol,srow,ecol,erow:olevariant;
ColWidth,ColW,ni:Integer;
ColWc:string;
begin
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
bbRC:=tbbstructRC.Create(Application);
bbRC.Label1.Caption :='列宽';
bbRC.Caption:='列宽';
Cell1.DoGetColWidth(sCol,ColWidth);
ColWc:=IntToStr(ColWidth);
for ni:=scol+1 to ecol do
begin
Cell1.DoGetColWidth(ni,ColW);
if ColWidth<>ColW then
begin
ColWc:='';
Break;
end;
end;
BbRC.Edit1.Text :=ColWc;
if bbRc.ShowModal = mrOk then
if (bbrc.Edit1.text='') or (strtoint(bbrc.edit1.text)<=0) then
showmessage('列宽设置错误!')
else
Cell1.DoSetColWidthEx(scol,ecol,strtoint(bbrc.Edit1.Text),bbrc.combobox1.itemindex);
Cell1.DoRedrawAll ;
end;
procedure TFormJtBbGs.A2Click(Sender: TObject);
{关于}
//var
// bbabout:tBbaboutbox;
begin
{ if HandleAllocated then
begin
BbAbout:=Tbbaboutbox.create(application);
bbabout.showmodal;
end; }
// bbabout.free;
end;
procedure TFormJtBbGs.WMSysCommand(var Msg:TWMSysCommand);
//退出系统
var
nts:smallint;
begin
if Msg.CmdType =SC_CLOSE then
begin
nts:=messagedlg('是否要保存所做的修改?',mtcustom,[mbyes,mbno,mbcancel],0);
case nts of
mryes:
begin
Toolbutton3.Click ;
inherited;
end;
mrno: inherited;
mrcancel: exit;
end;
end
else
inherited;
end;
procedure TFormJtBbGs.ToolButton28Click(Sender: TObject);
{var
scol,srow,ecol,erow:olevariant;
DataType,Typ:smallint;
nret:smallint; }
begin
{ //设置数据
if not cell1.dogetselectrange(scol,srow,ecol,erow) then
begin
scol:= cell1.DoGetCurrentCol();
srow:= cell1.DoGetCurrentRow();
ecol:=scol;
erow:=srow;
end;
if Sender=ToolButton29 then
begin
Typ:=1; //删除
DataType:=0;
end
else
begin
if Sender=ToolButton28 then
DataType :=0 //数值
else
DataType :=1; //字符
Typ :=0; //增加
end;
{ nret:=RangSav(_CurrentTaskNumber,_BbNumber,SCol,SRow,ECol,ERow,DataType,Typ);
if nret =0 then
showmessage('存盘成功。')
else
showmessage('存盘失败!'); }
end;
procedure TFormJtBbGs.ToolButton1Click(Sender: TObject);
//另存为文件
var
cfile :widestring;
begin
cfile:='';
if savedialog1.Execute then
cfile:=savedialog1.FileName;
if cfile<>'' then
begin
if cell1.DoSaveFile(cfile)>0 then
showmessage('存盘成功:'+cfile)
else
showmessage('存盘失败!')
end;
end;
procedure TFormJtBbGs.ToolButton32Click(Sender: TObject);
var
nts:smallint;
begin
nts:=messagedlg('是否要保存所做的修改?',mtcustom,[mbyes,mbno,mbcancel],0);
case nts of
mryes:
begin
Toolbutton3.Click ;
close;
end;
mrno: close;
mrcancel: exit;
end;
end;
procedure TFormJtBbGs.ToolButton48Click(Sender: TObject);
var
col,row:integer;
begin
col:=cell1.DoGetCurrentCol;
row:=cell1.DoGetCurrentRow;
cell1.DoInputFormula(col,row);
end;
procedure TFormJtBbGs.Cell1ExecuteUserFunc(Sender: TObject;
const name: WideString; rettype, paranum: Smallint;
var paratype: Integer; var funcResult: OleVariant);
{var
para0,para1,para2,para3:olevariant;
dp0,dp1:Double;
cp0,cp1,cret,cdt:String;
funcret:olevariant;
d1 : TDate; }
begin
{ funcret:=0;
D1:= ;
if (uppercase(name) = 'GETDATA') then
begin
cp0 := cell1.DoFetchFuncStringParameter(0);
dp0 := cell1.DoFetchFuncDoubleParameter(1);
dp1 := cell1.DoFetchFuncDoubleParameter(2);
cp1 := cell1.DoFetchFuncStringParameter(3);
cdt := dtos(strtodate(bbdate),6);
funcret := fGetDatadpt(cp1,cp0,cdt,trunc(dp0),trunc(dp1));
end }
funcresult :=0; // funcret;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -