2010-05-01 18:10:38 +00:00
|
|
|
unit mainform;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2010-05-25 09:11:02 +00:00
|
|
|
StdCtrls, Grids, EditBtn, ExtCtrls, fpspreadsheetchart, fpspreadsheetgrid,
|
|
|
|
TAGraph, TASeries;
|
2010-05-01 18:10:38 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TFPSChartForm }
|
|
|
|
|
|
|
|
TFPSChartForm = class(TForm)
|
|
|
|
btnCreateGraphic: TButton;
|
2010-05-25 09:11:02 +00:00
|
|
|
btnLoadSpreadsheet: TButton;
|
|
|
|
editSourceFile: TFileNameEdit;
|
|
|
|
Label1: TLabel;
|
|
|
|
Label2: TLabel;
|
|
|
|
editXAxis: TLabeledEdit;
|
|
|
|
EditYAxis: TLabeledEdit;
|
2010-05-01 18:10:38 +00:00
|
|
|
MyChart: TChart;
|
|
|
|
FPSChartSource: TsWorksheetChartSource;
|
|
|
|
MyChartLineSeries: TLineSeries;
|
|
|
|
WorksheetGrid: TsWorksheetGrid;
|
|
|
|
procedure btnCreateGraphicClick(Sender: TObject);
|
2010-05-25 09:11:02 +00:00
|
|
|
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
2010-05-01 18:10:38 +00:00
|
|
|
private
|
|
|
|
{ private declarations }
|
|
|
|
public
|
|
|
|
{ public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
FPSChartForm: TFPSChartForm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2010-05-25 09:11:02 +00:00
|
|
|
uses
|
|
|
|
// FPSpreadsheet and supported formats
|
|
|
|
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
|
|
|
|
|
2010-05-01 18:10:38 +00:00
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
{ TFPSChartForm }
|
|
|
|
|
|
|
|
procedure TFPSChartForm.btnCreateGraphicClick(Sender: TObject);
|
|
|
|
begin
|
2010-05-25 09:11:02 +00:00
|
|
|
FPSChartSource.LoadPropertiesFromStrings(editXAxis.Text, editYAxis.Text, '', '', '');
|
2010-05-01 18:10:38 +00:00
|
|
|
FPSChartSource.LoadFromWorksheetGrid(WorksheetGrid);
|
|
|
|
end;
|
|
|
|
|
2010-05-25 09:11:02 +00:00
|
|
|
procedure TFPSChartForm.btnLoadSpreadsheetClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Format: TsSpreadsheetFormat;
|
|
|
|
lExt: string;
|
|
|
|
begin
|
|
|
|
// First some logic to detect the format from the extension
|
|
|
|
lExt := ExtractFileExt(editSourceFile.Text);
|
|
|
|
if lExt = STR_EXCEL_EXTENSION then Format := sfExcel2
|
|
|
|
else if lExt = STR_OOXML_EXCEL_EXTENSION then Format := sfOOXML
|
|
|
|
else if lExt = STR_OPENDOCUMENT_CALC_EXTENSION then Format := sfOpenDocument
|
|
|
|
else raise Exception.Create('Invalid File Extension');
|
|
|
|
|
|
|
|
// Now the actual loading
|
|
|
|
WorksheetGrid.LoadFromSpreadsheetFile(editSourceFile.Text, Format);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TFPSChartForm.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
|
|
|
|
end;
|
|
|
|
|
2010-05-01 18:10:38 +00:00
|
|
|
end.
|
|
|
|
|