From 00260da6875a06d9fc2e581b7692bbf475597613 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Thu, 16 Jun 2011 07:55:24 +0000 Subject: [PATCH] fpspreadsheet: String typo fixed and adds a new convinience routine to the grid code git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1682 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/fpschart/fpschart.lpi | 21 +++++---------- .../examples/fpschart/mainform.lfm | 26 +++++++++---------- .../examples/fpschart/mainform.pas | 13 +--------- .../examples/other/test_write_formula.pas | 3 ++- components/fpspreadsheet/fpspreadsheet.pas | 4 +-- .../fpspreadsheet/fpspreadsheetgrid.pas | 17 +++++++++++- 6 files changed, 40 insertions(+), 44 deletions(-) diff --git a/components/fpspreadsheet/examples/fpschart/fpschart.lpi b/components/fpspreadsheet/examples/fpschart/fpschart.lpi index 4610fff23..78ea7da88 100644 --- a/components/fpspreadsheet/examples/fpschart/fpschart.lpi +++ b/components/fpspreadsheet/examples/fpschart/fpschart.lpi @@ -1,15 +1,10 @@ - + - - - - - @@ -17,8 +12,11 @@ - + + + + @@ -59,19 +57,14 @@ - + - + - - - - - diff --git a/components/fpspreadsheet/examples/fpschart/mainform.lfm b/components/fpspreadsheet/examples/fpschart/mainform.lfm index 6260e0ad5..93c778aae 100644 --- a/components/fpspreadsheet/examples/fpschart/mainform.lfm +++ b/components/fpspreadsheet/examples/fpschart/mainform.lfm @@ -7,7 +7,7 @@ object FPSChartForm: TFPSChartForm ClientHeight = 382 ClientWidth = 700 OnCreate = FormCreate - LCLVersion = '0.9.29' + LCLVersion = '0.9.31' object MyChart: TChart Left = 352 Height = 240 @@ -15,8 +15,7 @@ object FPSChartForm: TFPSChartForm Width = 336 AxisList = < item - Alignment = calLeft - Title.Font.Orientation = 900 + Title.LabelFont.Orientation = 900 end item Alignment = calBottom @@ -31,7 +30,6 @@ object FPSChartForm: TFPSChartForm ParentColor = False object MyChartLineSeries: TLineSeries LinePen.Color = clRed - SeriesColor = clRed Source = FPSChartSource end end @@ -64,7 +62,7 @@ object FPSChartForm: TFPSChartForm end object editSourceFile: TFileNameEdit Left = 152 - Height = 22 + Height = 25 Top = 48 Width = 136 DialogOptions = [] @@ -79,7 +77,7 @@ object FPSChartForm: TFPSChartForm Left = 14 Height = 18 Top = 51 - Width = 130 + Width = 136 Caption = 'Source Spreadsheet:' ParentColor = False end @@ -94,7 +92,7 @@ object FPSChartForm: TFPSChartForm end object editXAxis: TLabeledEdit Left = 64 - Height = 22 + Height = 25 Top = 80 Width = 80 EditLabel.AnchorSideLeft.Control = editXAxis @@ -102,10 +100,10 @@ object FPSChartForm: TFPSChartForm EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideRight.Control = editXAxis EditLabel.AnchorSideBottom.Control = editXAxis - EditLabel.Left = 17 + EditLabel.Left = 18 EditLabel.Height = 18 - EditLabel.Top = 82 - EditLabel.Width = 44 + EditLabel.Top = 83 + EditLabel.Width = 43 EditLabel.Caption = 'X-Axis:' EditLabel.ParentColor = False LabelPosition = lpLeft @@ -114,7 +112,7 @@ object FPSChartForm: TFPSChartForm end object EditYAxis: TLabeledEdit Left = 208 - Height = 22 + Height = 25 Top = 80 Width = 80 EditLabel.AnchorSideLeft.Control = EditYAxis @@ -122,10 +120,10 @@ object FPSChartForm: TFPSChartForm EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideRight.Control = EditYAxis EditLabel.AnchorSideBottom.Control = EditYAxis - EditLabel.Left = 161 + EditLabel.Left = 164 EditLabel.Height = 18 - EditLabel.Top = 82 - EditLabel.Width = 44 + EditLabel.Top = 83 + EditLabel.Width = 41 EditLabel.Caption = 'Y-Axis:' EditLabel.ParentColor = False LabelPosition = lpLeft diff --git a/components/fpspreadsheet/examples/fpschart/mainform.pas b/components/fpspreadsheet/examples/fpschart/mainform.pas index b9ba09255..78f6c84bf 100644 --- a/components/fpspreadsheet/examples/fpschart/mainform.pas +++ b/components/fpspreadsheet/examples/fpschart/mainform.pas @@ -54,19 +54,8 @@ begin end; 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); + WorksheetGrid.LoadFromSpreadsheetFile(editSourceFile.Text); end; procedure TFPSChartForm.FormCreate(Sender: TObject); diff --git a/components/fpspreadsheet/examples/other/test_write_formula.pas b/components/fpspreadsheet/examples/other/test_write_formula.pas index 7046b5022..78954fb42 100644 --- a/components/fpspreadsheet/examples/other/test_write_formula.pas +++ b/components/fpspreadsheet/examples/other/test_write_formula.pas @@ -10,7 +10,8 @@ program test_write_formula; {$mode delphi}{$H+} uses - Classes, SysUtils, fpspreadsheet, xlsbiff8, fpsopendocument, + Classes, SysUtils, + fpspreadsheet, xlsbiff5, xlsbiff8, fpsopendocument, laz_fpspreadsheet, fpsconvencoding; var diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas index 703f92021..54b868c56 100755 --- a/components/fpspreadsheet/fpspreadsheet.pas +++ b/components/fpspreadsheet/fpspreadsheet.pas @@ -751,8 +751,8 @@ begin FWorksheets := TFPList.Create; // In the future: add support for translations - lpUnsupportedReadFormat := 'Tryed to read a spreadsheet using an unsupported format'; - lpUnsupportedWriteFormat := 'Tryed to write a spreadsheet using an unsupported format'; + lpUnsupportedReadFormat := 'Tried to read a spreadsheet using an unsupported format'; + lpUnsupportedWriteFormat := 'Tried to write a spreadsheet using an unsupported format'; end; {@@ diff --git a/components/fpspreadsheet/fpspreadsheetgrid.pas b/components/fpspreadsheet/fpspreadsheetgrid.pas index 36ed1cd4d..448eff91c 100644 --- a/components/fpspreadsheet/fpspreadsheetgrid.pas +++ b/components/fpspreadsheet/fpspreadsheetgrid.pas @@ -31,7 +31,8 @@ type { methods } constructor Create(AOwner: TComponent); override; procedure LoadFromWorksheet(AWorksheet: TsWorksheet); - procedure LoadFromSpreadsheetFile(AFileName: string; AFormat: TsSpreadsheetFormat; AWorksheetIndex: Integer = 0); + procedure LoadFromSpreadsheetFile(AFileName: string; AFormat: TsSpreadsheetFormat; AWorksheetIndex: Integer = 0); overload; + procedure LoadFromSpreadsheetFile(AFileName: string; AWorksheetIndex: Integer = 0); overload; procedure SaveToWorksheet(AWorksheet: TsWorksheet); property DisplayFixedColRow: Boolean read FDisplayFixedColRow write SetDisplayFixedColRow; end; @@ -236,6 +237,20 @@ begin end; end; +procedure TsCustomWorksheetGrid.LoadFromSpreadsheetFile(AFileName: string; + AWorksheetIndex: Integer); +var + lWorkbook: TsWorkbook; +begin + lWorkbook := TsWorkbook.Create; + try + lWorkbook.ReadFromFile(AFileName); + LoadFromWorksheet(lWorkbook.GetWorksheetByIndex(AWorksheetIndex)); + finally + lWorkbook.Free; + end; +end; + procedure TsCustomWorksheetGrid.SaveToWorksheet(AWorksheet: TsWorksheet); var x, y: Integer;