procedure TForm1.ColorComboBox1Change(Sender: TObject)
//设置字体颜色
var
a:F1CellFormat;
begin
a:=form1.FBook1.getcellformat;
a.fontcolor:=colorcombobox1.ColorValue;
form1.fbook1.setcellformat(a);
end;
procedure TForm1.FBook1SelChange(Sender: TObject)
//返回当前单元的属性
var
a:F1CellFormat;
begin
a:=form1.FBook1.GetCellFormat;
colorcombobox1.ColorValue:=a.FontColor;
lmdfontcombobox1.SelectedFont :=a.FontName;
form1.LMDFontSizeComboBox1.FontSize :=a.FontSize
dfscolorbutton1.Color:=a.PatternFG;
toolbutton21.Down:=a.FontBold;
toolbutton22.down:=a.FontItalic;
toolbutton23.Down :=a.FontUnderline
toolbutton34.Down:=a.FontStrikeout;
case a.AlignHorizontal of
2: toolbutton25.Down:=true;
3: toolbutton26.Down :=true;
4: toolbutton27.down:=true;
7: toolbutton29.down:=true;
else
begin
toolbutton25.Down:=false;
toolbutton26.Down :=false;
toolbutton27.down:=false;
toolbutton29.down:=false;
end;
end;
end;
procedure TForm1.ToolButton16Click(Sender: TObject)
//排序对话框
begin
fbook1.SortDlg;
end;
procedure TForm1.LMDFontComboBox1Change(Sender: TObject)
//设置字体名称
var
a:F1CellFormat;
begin
a:=form1.FBook1.getcellformat;
a.FontName:=form1.LMDFontComboBox1.SelectedFont;
form1.fbook1.setcellformat(a);
end;
procedure TForm1.LMDFontSizeComboBox1Change(Sender: TObject)
//设置字体大小
var
a:f1cellformat;
begin
a:=form1.fbook1.getcellformat;
a.FontSize:=form1.LMDFontSizeComboBox1.FontSize
form1.FBook1.SetCellFormat(a);
end;
procedure TForm1.ToolButton21Click(Sender: TObject)
//设置字体的粗细
var
cellformat:f1cellformat;
begin
cellformat:=fbook1.GetCellFormat;
if toolbutton21.Down then cellformat.FontBold:=true
else
cellformat.FontBold :=false;
if toolbutton22.Down then cellformat.FontItalic :=true
else
cellformat.FontItalic:=false;
if toolbutton34.Down then cellformat.FontStrikeout:=true
else
cellformat.FontStrikeout:=false;
if toolbutton23.Down then cellformat.FontUnderline :=true
else
cellformat.FontUnderline:=false;
fbook1.SetCellFormat(cellformat);
end;
procedure TForm1.ToolButtonClick(Sender: TObject)
//设置单元格内容在单元中的位置
var
cellformat:f1cellformat;
begin
cellformat:=fbook1.GetCellFormat;
case TControl(Sender).tag of
0: cellformat.AlignHorizontal:=2
//左对齐
1: cellformat.AlignHorizontal:=3
//右对齐
2: cellformat.AlignHorizontal:=4
//中间对齐
3: cellformat.AlignHorizontal:=7
//居中对齐
end;
fbook1.SetCellFormat(cellformat);
end;
procedure TForm1.dfsColorButton1Exit(Sender: TObject)
//对所选的单元进行设置颜色
begin
fbook1.SetPattern(1,dfscolorbutton1.color,dfscolorbutton1.color);
end;