2023-11-21 22:03:20 +00:00
|
|
|
unit main;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2023-11-28 23:04:27 +00:00
|
|
|
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
2023-11-21 22:03:20 +00:00
|
|
|
TAGraph,
|
|
|
|
fpSpreadsheet, fpsTypes, fpsOpenDocument,
|
|
|
|
fpSpreadsheetCtrls, fpSpreadsheetGrid, fpSpreadsheetChart;
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
2023-11-28 23:04:27 +00:00
|
|
|
Button1: TButton;
|
|
|
|
Button2: TButton;
|
2023-11-21 22:03:20 +00:00
|
|
|
Chart1: TChart;
|
2023-11-28 23:04:27 +00:00
|
|
|
ComboBox1: TComboBox;
|
|
|
|
Label1: TLabel;
|
|
|
|
OpenDialog1: TOpenDialog;
|
|
|
|
Panel1: TPanel;
|
2023-11-21 22:03:20 +00:00
|
|
|
Splitter1: TSplitter;
|
|
|
|
sWorkbookSource1: TsWorkbookSource;
|
|
|
|
sWorksheetGrid1: TsWorksheetGrid;
|
2023-11-28 23:04:27 +00:00
|
|
|
procedure Button1Click(Sender: TObject);
|
|
|
|
procedure Button2Click(Sender: TObject);
|
|
|
|
procedure ComboBox1CloseUp(Sender: TObject);
|
2023-11-21 22:03:20 +00:00
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
private
|
|
|
|
sChartLink: TsWorkbookChartLink;
|
2023-11-28 23:04:27 +00:00
|
|
|
procedure LoadFile(AFileName: String);
|
2023-11-21 22:03:20 +00:00
|
|
|
|
|
|
|
public
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
const
|
2023-11-28 21:22:46 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/bars.ods';
|
|
|
|
FILE_NAME = '../../../other/chart/bubble.ods';
|
2023-11-27 22:41:30 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/area.ods';
|
2023-11-23 22:13:52 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/area-sameImg.ods';
|
2023-11-23 00:08:33 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/pie.ods';
|
|
|
|
// FILE_NAME = '../../../other/chart/scatter.ods';
|
2023-11-23 18:49:41 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/regression.ods';
|
2023-11-27 18:17:22 +00:00
|
|
|
// FILE_NAME = '../../../other/chart/radar.ods';
|
2023-11-21 22:03:20 +00:00
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
2023-11-28 23:04:27 +00:00
|
|
|
procedure TForm1.Button1Click(Sender: TObject);
|
|
|
|
begin
|
|
|
|
OpenDialog1.InitialDir := ExtractFilePath(Combobox1.Text);
|
|
|
|
OpenDialog1.FileName := '';
|
|
|
|
if OpenDialog1.Execute then
|
|
|
|
begin
|
|
|
|
Combobox1.Text := OpenDialog1.FileName;
|
|
|
|
LoadFile(OpenDialog1.FileName);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.Button2Click(Sender: TObject);
|
|
|
|
begin
|
|
|
|
LoadFile(Combobox1.Text);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Combobox1.Text := Combobox1.Items[Combobox1.ItemIndex];
|
|
|
|
LoadFile(Combobox1.Text);
|
|
|
|
end;
|
|
|
|
|
2023-11-21 22:03:20 +00:00
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
2023-11-28 23:04:27 +00:00
|
|
|
begin
|
|
|
|
if ParamCount > 0 then
|
|
|
|
begin
|
|
|
|
Combobox1.Text := ParamStr(1);
|
|
|
|
LoadFile(Combobox1.Text);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LoadFile(AFileName: String);
|
2023-11-21 22:03:20 +00:00
|
|
|
var
|
|
|
|
fn: String;
|
2023-11-30 23:20:34 +00:00
|
|
|
i: Integer;
|
2023-11-21 22:03:20 +00:00
|
|
|
begin
|
2023-11-28 23:04:27 +00:00
|
|
|
fn := ExpandFileName(AFileName);
|
|
|
|
if not FileExists(fn) then
|
|
|
|
begin
|
|
|
|
MessageDlg('File "' + fn + '" not found.', mtError, [mbOK], 0);
|
|
|
|
exit;
|
|
|
|
end;
|
2023-11-21 22:03:20 +00:00
|
|
|
|
|
|
|
sWorkbookSource1.FileFormat := sfOpenDocument;
|
|
|
|
if FileExists(fn) then
|
|
|
|
sWorkbookSource1.Filename := fn;
|
|
|
|
|
2023-11-30 23:20:34 +00:00
|
|
|
for i := 1 to sWorksheetGrid1.Worksheet.GetLastRowIndex+1 do
|
|
|
|
sWorksheetGrid1.AutoRowHeight(1);
|
|
|
|
|
2023-11-21 22:03:20 +00:00
|
|
|
sChartLink := TsWorkbookChartLink.Create(self);
|
|
|
|
sChartLink.Chart := Chart1;
|
|
|
|
sChartLink.WorkbookSource := sWorkbookSource1;
|
|
|
|
sChartLink.WorkbookChartIndex := 0;
|
|
|
|
end;
|
|
|
|
end.
|
|
|
|
|