📄 main.pas
字号:
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
PlotArea.ChartStyle.VaryColors := True;
TChartStylePie(PlotArea.ChartStyle).DonutHole := 50;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button10Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
PlotArea.ChartType := xctLine;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
if cbLineMarkers.ItemIndex = 0 then begin
PlotArea.ChartStyle.HasDefDataPoint := True;
PlotArea.ChartStyle.DefDataPoint.MarkerFormat.MarkerStyle := cmsNone;
end
else begin
Series[0].HasDefDataPoint := True;
Series[0].DefDataPoint.MarkerFormat.MarkerStyle := TChartMarkerStyle(cbLineMarkers.ItemIndex);
end;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button11Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
PlotArea.ChartType := xctPie;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
PlotArea.ChartStyle.VaryColors := True;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button12Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
PlotArea.ChartType := xctRadar;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button13Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
Series[0].Category := 'Sheet1!$B$1:$B$10';
PlotArea.ChartType := xctScatter;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button22Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$B$3:$E$3';
Series[0].Category := 'Sheet1!$B$2:$E$2';
with Series.Add do begin
Series[Series.Count - 1].Values := 'Sheet1!$B$5:$E$5';
Series[Series.Count - 1].Category := 'Sheet1!$B$4:$E$4';
end;
with Series.Add do begin
Series[Series.Count - 1].Values := 'Sheet1!$B$7:$E$7';
Series[Series.Count - 1].Category := 'Sheet1!$B$6:$E$6';
end;
with Series.Add do begin
Series[Series.Count - 1].Values := 'Sheet1!$B$9:$E$9';
Series[Series.Count - 1].Category := 'Sheet1!$B$8:$E$8';
end;
PlotArea.ChartType := xctScatter;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button14Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
Series.Add;
Series[1].Values := 'Sheet1!$B$1:$B$10';
Series.Add;
Series[2].Values := 'Sheet1!$C$1:$C$10';
Series.Add;
Series[3].Values := 'Sheet1!$D$1:$D$10';
Series.Add;
Series[4].Values := 'Sheet1!$E$1:$E$10';
PlotArea.ChartType := xctSurface;
PlotArea.HasLegend := cbLegend.Checked;
PlotArea.Is3D := cb3D.Checked;
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.Frame.AreaFormat.ForegroundColor := xcPaleGreen;
end;
if edTitle.Text <> '' then begin
with XLS.Sheets[0].Charts[0].Labels.Add do begin
LabelType := cltTitle;
Text := edTitle.Text;
end;
end;
end;
procedure TfrmMain.Button16Click(Sender: TObject);
begin
dlgOpen.FileName := edPictFile.Text;
if dlgOpen.Execute then
edPictFile.Text := dlgOpen.FileName;
end;
procedure TfrmMain.Button15Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
PlotArea.Frame.HasFillEffects := True;
PlotArea.Frame.FillEffects.FillEffectPicture(edPictFile.Text);
PlotArea.ChartStyle.Legend.HasFrame := True;
PlotArea.ChartStyle.Legend.Frame.HasFillEffects := True;
PlotArea.ChartStyle.Legend.Frame.FillEffects.FillEffectPicture(edPictFile.Text);
end;
end;
procedure TfrmMain.Button18Click(Sender: TObject);
begin
if TfrmExcelColorSelect.Create(Application).Execute(FGradientColor1) then
shpColor1.Brush.Color := ExcelColorPalette[Integer(FGradientColor1)];
end;
procedure TfrmMain.Button19Click(Sender: TObject);
begin
if TfrmExcelColorSelect.Create(Application).Execute(FGradientColor2) then
shpColor2.Brush.Color := ExcelColorPalette[Integer(FGradientColor2)];
end;
procedure TfrmMain.Button17Click(Sender: TObject);
begin
XLS.Sheets[0].Charts.Clear;
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
PlotArea.Frame.HasFillEffects := True;
PlotArea.Frame.FillEffects.FillEffectGradient(FGradientColor1,FGradientColor2,TGradientFillStyle(cbGradientStyle.ItemIndex));
PlotArea.ChartStyle.Legend.HasFrame := True;
PlotArea.ChartStyle.Legend.Frame.HasFillEffects := True;
PlotArea.ChartStyle.Legend.Frame.FillEffects.FillEffectGradient(FGradientColor1,FGradientColor2,TGradientFillStyle(cbGradientStyle.ItemIndex));
end;
end;
procedure TfrmMain.Button20Click(Sender: TObject);
var
i: integer;
begin
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
for i := 0 to 9 do begin
with Series[0].DataPoints.Add do begin
PointIndex := i;
AreaFormat.ForegroundColor := TExcelColor(Random(High(ExcelColorPalette)));
end;
end;
end;
end;
procedure TfrmMain.Button21Click(Sender: TObject);
var
i: integer;
begin
with XLS.Sheets[0].AddChart do begin
Col1 := 5;
Col2 := 11;
for i := 0 to 9 do begin
with Labels.Add do begin
LabelType := cltDataPoint;
DataPointIndex := i;
Text := ShortMonthNames[i + 1];
end;
end;
end;
end;
procedure TfrmMain.FormDestroy(Sender: TObject);
begin
FFontA.Free;
FFontB.Free;
end;
procedure TfrmMain.Button23Click(Sender: TObject);
begin
dlgFont.Font.Assign(FFontA);
if dlgFont.Execute then
FFontA.Assign(dlgFont.Font);
end;
procedure TfrmMain.Button24Click(Sender: TObject);
begin
dlgFont.Font.Assign(FFontB);
if dlgFont.Execute then
FFontB.Assign(dlgFont.Font);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -