From 6721996b7a77e31e7d650b4788fab2c187887afa Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 17 Nov 2014 16:59:22 +0000 Subject: [PATCH] fpspreadsheet: Add loading and saving by actions to fpsctrls demo. Add action to copy format (not working yet). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3737 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../fpspreadsheet/examples/fpsctrls/main.lfm | 526 ++++++++++++------ .../fpspreadsheet/examples/fpsctrls/main.pas | 82 ++- components/fpspreadsheet/fpsactions.pas | 58 ++ .../fpspreadsheet/fpspreadsheetctrls.pas | 20 +- 4 files changed, 486 insertions(+), 200 deletions(-) diff --git a/components/fpspreadsheet/examples/fpsctrls/main.lfm b/components/fpspreadsheet/examples/fpsctrls/main.lfm index b83bb2657..776cc4740 100644 --- a/components/fpspreadsheet/examples/fpsctrls/main.lfm +++ b/components/fpspreadsheet/examples/fpsctrls/main.lfm @@ -1,70 +1,31 @@ object Form1: TForm1 - Left = 414 + Left = 541 Height = 600 - Top = 118 - Width = 925 + Top = 214 + Width = 922 Caption = 'Form1' - ClientHeight = 580 - ClientWidth = 925 + ClientHeight = 575 + ClientWidth = 922 Menu = MainMenu ShowHint = True LCLVersion = '1.3' - object Panel1: TPanel - Left = 0 - Height = 36 - Top = 50 - Width = 925 - Align = alTop - BevelOuter = bvNone - ClientHeight = 36 - ClientWidth = 925 - TabOrder = 0 - object Button1: TButton - Left = 8 - Height = 25 - Top = 6 - Width = 75 - Caption = 'Open...' - OnClick = Button1Click - TabOrder = 0 - end - object CellIndicator: TsCellIndicator - Left = 95 - Height = 23 - Top = 4 - Width = 80 - TabOrder = 1 - Text = 'A1' - WorkbookSource = WorkbookSource - end - object CellEdit: TsCellEdit - Left = 184 - Height = 23 - Top = 4 - Width = 731 - Anchors = [akTop, akLeft, akRight] - TabOrder = 2 - WantReturns = False - WorkbookSource = WorkbookSource - end - end object WorkbookTabControl: TsWorkbookTabControl Left = 0 - Height = 494 - Top = 86 - Width = 672 + Height = 490 + Top = 85 + Width = 669 TabIndex = 0 Tabs.Strings = ( 'Sheet1' ) Align = alClient - TabOrder = 1 + TabOrder = 0 WorkbookSource = WorkbookSource object WorksheetGrid: TsWorksheetGrid Left = 2 - Height = 469 - Top = 23 - Width = 668 + Height = 460 + Top = 28 + Width = 665 FrozenCols = 0 FrozenRows = 0 ReadFormulas = False @@ -76,13 +37,14 @@ object Form1: TForm1 Font.Color = clBlack Font.Height = -13 Font.Name = 'Arial' - Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goEditing, goThumbTracking, goSmoothScroll] + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goEditing, goThumbTracking, goDblClickAutoSize, goSmoothScroll, goHeaderHotTracking] ParentFont = False RowCount = 101 TabOrder = 1 TitleFont.Color = clBlack TitleFont.Height = -13 TitleFont.Name = 'Arial' + TitleStyle = tsNative ColWidths = ( 50 64 @@ -115,9 +77,9 @@ object Form1: TForm1 end end object InspectorTabControl: TTabControl - Left = 677 - Height = 494 - Top = 86 + Left = 674 + Height = 490 + Top = 85 Width = 248 OnChange = InspectorTabControlChange TabIndex = 0 @@ -128,15 +90,17 @@ object Form1: TForm1 'Cell properties' ) Align = alRight - TabOrder = 2 + TabOrder = 1 + Visible = False object Inspector: TsSpreadsheetInspector Left = 2 - Height = 469 - Top = 23 + Height = 460 + Top = 28 Width = 244 Align = alClient RowCount = 25 TabOrder = 1 + TitleStyle = tsNative Strings.Strings = ( 'FileName=' 'FileFormat=sfExcel8' @@ -144,7 +108,7 @@ object Form1: TForm1 'Options=boAutoCalc, boCalcBeforeSaving, boReadFormulas' 'FormatSettings=' ' ThousandSeparator=.' - ' DecimalSeparator=.' + ' DecimalSeparator=,' ' ListSeparator=;' ' DateSeparator=.' ' TimeSeparator=:' @@ -170,114 +134,115 @@ object Form1: TForm1 WorkbookSource = WorkbookSource Mode = imWorkbook ColWidths = ( - 111 - 112 + 109 + 110 ) end end object Splitter1: TSplitter - Left = 672 - Height = 494 - Top = 86 + Left = 669 + Height = 490 + Top = 85 Width = 5 Align = alRight ResizeAnchor = akRight end object ToolBar1: TToolBar Left = 0 - Height = 26 + Height = 28 Top = 24 - Width = 925 + Width = 922 AutoSize = True - ButtonHeight = 24 + ButtonHeight = 26 + ButtonWidth = 24 Caption = 'ToolBar1' - EdgeBorders = [ebBottom] + EdgeBorders = [] Images = ImageList - TabOrder = 4 + TabOrder = 3 object ToolButton4: TToolButton - Left = 235 - Height = 24 + Left = 265 + Height = 26 Top = 0 Width = 3 Caption = 'ToolButton4' Style = tbsDivider end object ToolButton6: TToolButton - Left = 238 + Left = 268 Top = 0 Action = AcFontBold end object ToolButton7: TToolButton - Left = 261 + Left = 292 Top = 0 Action = AcFontItalic end object ToolButton8: TToolButton - Left = 284 + Left = 316 Top = 0 Action = AcFontUnderline end object ToolButton10: TToolButton - Left = 330 - Height = 24 + Left = 364 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton10' Style = tbsDivider end object ToolButton11: TToolButton - Left = 307 + Left = 340 Top = 0 Action = AcFontStrikeout end object ToolButton12: TToolButton - Left = 335 + Left = 369 Top = 0 Action = AcHorAlignLeft end object ToolButton13: TToolButton - Left = 358 + Left = 393 Top = 0 Action = AcHorAlignCenter end object ToolButton14: TToolButton - Left = 381 + Left = 417 Top = 0 Action = AcHorAlignRight end object ToolButton15: TToolButton - Left = 404 - Height = 24 + Left = 441 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton15' Style = tbsDivider end object ToolButton16: TToolButton - Left = 409 + Left = 446 Top = 0 Action = AcVertAlignTop end object ToolButton17: TToolButton - Left = 432 + Left = 470 Top = 0 Action = AcVertAlignCenter end object ToolButton18: TToolButton - Left = 455 + Left = 494 Top = 0 Action = AcVertAlignBottom end object ToolButton19: TToolButton - Left = 478 - Height = 24 + Left = 518 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton19' Style = tbsDivider end object ToolButton20: TToolButton - Left = 546 + Left = 523 Hint = 'Number format' Top = 0 Caption = 'ToolButton20' @@ -286,7 +251,7 @@ object Form1: TForm1 Style = tbsDropDown end object ToolButton21: TToolButton - Left = 604 + Left = 583 Hint = 'Currency format' Top = 0 Caption = 'ToolButton21' @@ -295,20 +260,20 @@ object Form1: TForm1 Style = tbsDropDown end object ToolButton22: TToolButton - Left = 581 + Left = 559 Top = 0 Action = AcNumFormatPercentage end object ToolButton23: TToolButton - Left = 709 - Height = 24 + Left = 828 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton23' Style = tbsDivider end object ToolButton24: TToolButton - Left = 639 + Left = 619 Hint = 'Date format' Top = 0 Caption = 'ToolButton24' @@ -317,7 +282,7 @@ object Form1: TForm1 Style = tbsDropDown end object ToolButton25: TToolButton - Left = 674 + Left = 655 Hint = 'Time format' Top = 0 Caption = 'ToolButton25' @@ -326,35 +291,35 @@ object Form1: TForm1 Style = tbsDropDown end object ToolButton26: TToolButton - Left = 714 + Left = 691 Top = 0 Action = AcDecDecimals end object ToolButton27: TToolButton - Left = 737 + Left = 715 Top = 0 Action = AcIncDecimals end object ToolButton29: TToolButton - Left = 1 + Left = 30 Top = 0 Action = AcCellFontDialog end object ToolButton30: TToolButton - Left = 518 + Left = 768 Top = 0 Action = AcBackgroundColorDialog end object ToolButton31: TToolButton - Left = 541 - Height = 24 + Left = 857 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton31' Style = tbsDivider end object TbBorders: TToolButton - Left = 483 + Left = 792 Hint = 'Top border' Top = 0 Caption = 'Top' @@ -363,11 +328,11 @@ object Form1: TForm1 Style = tbsDropDown end object FontnameCombo: TsFontNameCombobox - Left = 24 - Height = 23 + Left = 54 + Height = 28 Top = 0 Width = 151 - ItemHeight = 15 + ItemHeight = 20 ItemIndex = 62 Items.Strings = ( '@Arial Unicode MS' @@ -1163,11 +1128,11 @@ object Form1: TForm1 WorkbookSource = WorkbookSource end object sFontSizeCombobox1: TsFontSizeCombobox - Left = 175 - Height = 23 + Left = 205 + Height = 28 Top = 0 Width = 60 - ItemHeight = 15 + ItemHeight = 20 ItemIndex = 2 Items.Strings = ( '8' @@ -1193,47 +1158,66 @@ object Form1: TForm1 WorkbookSource = WorkbookSource end object ToolButton3: TToolButton - Left = 760 - Height = 24 + Left = 739 + Height = 26 Top = 0 Width = 5 Caption = 'ToolButton3' Style = tbsDivider end object ToolButton5: TToolButton - Left = 765 + Left = 833 Top = 0 Action = AcMergeCells end + object ToolButton36: TToolButton + Left = 744 + Top = 0 + Action = AcWordWrap + end + object ToolButton37: TToolButton + Left = 1 + Top = 0 + Action = AcCopyFormat + end + object ToolButton38: TToolButton + Left = 25 + Height = 26 + Top = 0 + Width = 5 + Caption = 'ToolButton38' + Style = tbsDivider + end end object ToolBar2: TToolBar Left = 0 Height = 24 Top = 0 - Width = 925 + Width = 922 AutoSize = True ButtonHeight = 24 + ButtonWidth = 24 Caption = 'ToolBar2' EdgeBorders = [] Images = ImageList - TabOrder = 5 + TabOrder = 4 object ToolButton32: TToolButton - Left = 1 + Left = 54 Top = 0 Action = AcAddWorksheet end object ToolButton33: TToolButton - Left = 24 + Left = 78 Top = 0 Action = AcDeleteWorksheet end object ToolButton34: TToolButton - Left = 47 + Left = 102 Top = 0 Action = acRenameWorksheet end object ToolButton1: TToolButton - Left = 70 + Left = 126 Height = 24 Top = 0 Width = 5 @@ -1241,10 +1225,85 @@ object Form1: TForm1 Style = tbsDivider end object ToolButton2: TToolButton - Left = 75 + Left = 131 Top = 0 Action = AcFileExit end + object ToolButton9: TToolButton + Left = 1 + Top = 0 + Action = AcFileOpen + end + object ToolButton28: TToolButton + Left = 49 + Height = 24 + Top = 0 + Width = 5 + Caption = 'ToolButton28' + Style = tbsDivider + end + object ToolButton35: TToolButton + Left = 25 + Top = 0 + Action = AcFileSaveAs + end + end + object ToolBar3: TToolBar + Left = 0 + Height = 28 + Top = 52 + Width = 922 + AutoSize = True + Caption = 'ToolBar3' + Constraints.MinHeight = 28 + EdgeBorders = [ebBottom] + TabOrder = 5 + object Panel2: TPanel + Left = 1 + Height = 26 + Top = 0 + Width = 138 + Align = alLeft + BevelOuter = bvNone + ClientHeight = 26 + ClientWidth = 138 + TabOrder = 0 + object CellIndicator: TsCellIndicator + Left = 0 + Height = 28 + Top = 0 + Width = 138 + Align = alTop + TabOrder = 0 + Text = 'A1' + WorkbookSource = WorkbookSource + end + end + object CellEdit: TsCellEdit + Left = 144 + Height = 26 + Top = 0 + Width = 778 + Align = alClient + TabOrder = 1 + WantReturns = False + WorkbookSource = WorkbookSource + end + object Splitter2: TSplitter + Left = 139 + Height = 26 + Top = 0 + Width = 5 + end + end + object Splitter3: TSplitter + Cursor = crVSplit + Left = 0 + Height = 5 + Top = 80 + Width = 922 + Align = alTop + ResizeAnchor = akTop end object WorkbookSource: TsWorkbookSource AutoDetectFormat = False @@ -1376,6 +1435,7 @@ object Form1: TForm1 WorkbookSource = WorkbookSource Caption = 'AcWordWrap' Hint = 'Word-wrapped text' + ImageIndex = 24 end object AcTextRotHor: TsTextRotationAction Category = 'FPSpreadsheet' @@ -1946,12 +2006,44 @@ object Form1: TForm1 Hint = 'Merge cells' ImageIndex = 23 end + object AcFileOpen: TFileOpen + Category = 'File' + Caption = '&Open ...' + Dialog.Filter = 'All spreadsheet files|*.xls;*.xlsx;*.ods;*.csv|All Excel files (*.xls, *.xlsx)|*.xls;*.xlsx|Excel XML spreadsheet (*.xlsx)|*.xlsx|Excel 97-2003 spreadsheets (*.xls)|*.xls|Excel 5 spreadsheet (*.xls)|*.xls|Excel 2.1 spreadsheets (*.xls)|*.xls|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Comma-delimited files (*.csv)|*.csv' + Dialog.Options = [ofExtensionDifferent, ofFileMustExist, ofEnableSizing, ofViewDetail] + Hint = 'Open spreadsheet file' + ImageIndex = 44 + ShortCut = 16463 + OnAccept = AcFileOpenAccept + end + object AcFileSaveAs: TFileSaveAs + Category = 'File' + Caption = 'Save &as ...' + Dialog.Title = 'AcSaveFileAs' + Dialog.Filter = 'Excel XML spreadsheet (*.xlsx)|*.xlsx|Excel 97-2003 spreadsheets (*.xls)|*.xls|Excel 5 spreadsheet (*.xls)|*.xls|Excel 2.1 spreadsheets (*.xls)|*.xls|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Comma-delimited files (*.csv)|*.csv|WikiTable (WikiMedia-Format, *.wikitable_wikimedia)|*.wikitable_wikimedia' + Hint = 'Save spreadsheet with a new name' + ImageIndex = 45 + OnAccept = AcFileSaveAsAccept + end + object AcCopyFormat: TsCopyFormatAction + Category = 'FPSpreadsheet' + WorkbookSource = WorkbookSource + Caption = 'Copy format' + Hint = 'Copy format' + ImageIndex = 46 + end + object AcViewInspector: TAction + Category = 'View' + AutoCheck = True + Caption = 'Inspector' + OnExecute = AcViewInspectorExecute + end end object ImageList: TImageList left = 176 top = 312 Bitmap = { - 4C69350000001000000010000000003F9300003F9300003F9300003F9424003F + 4C69370000001000000010000000003F9300003F9300003F9300003F9424003F 948A003E93CC004095CC004095CC004095CC004095CC004095CC004095CC0040 95CC004095CC00409599003F9400003F9300003F9324003F938A0E4B9CD33F76 C0EC5D90D4FF3365A9FFA0A0A0FFA9A9A9FFA9A9A9FFAAAAAAFFACACACFFAEAE @@ -3361,33 +3453,97 @@ object Form1: TForm1 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101810101012B000000330000 - 000D000000670000000D000000670000000D000000670000000D000000670000 - 000D0000004DFFFFFF00FFFFFF00FFFFFF000101012C010101AE0101012C0101 - 0100000000000000000000000000000000000000000000000000000000000000 - 00000000000DFFFFFF00FFFFFF00FFFFFF00000000360101012C010101B00101 - 012C010101000101010000000000000000000000000000000000000000000000 - 00000000006BFFFFFF00FFFFFF00FFFFFF000000000E010101000101012D0101 - 01B30101012D0101010001010100010101000000000000000000000000000000 - 00000000000EFFFFFF00FFFFFF00FFFFFF000000007100000000010101000101 - 012E010101B60101012E01010100010101000101010000000000000000000000 - 000000000071FFFFFF00FFFFFF00FFFFFF000000000F00000000010101000101 - 01000101012E010101B90101012F010101000101010001010100000000000000 - 00000000000FFFFFFF00FFFFFF00FFFFFF000000007800000000000000000101 - 0100010101000101012F010101BC010101300101010001010100000000000000 - 000000000078FFFFFF00FFFFFF00FFFFFF000000001000000000000000000101 - 0100010101000101010001010130010101C00101013101010100010101000000 - 000000000010FFFFFF00FFFFFF00FFFFFF000000008000000000000000000000 - 000001010100010101000101010001010131010101C401010132010101000000 - 000000000080FFFFFF00FFFFFF00FFFFFF000000001100000000010101000101 - 01000101010001010100010101000101010001010132010101C7010101320000 - 000000000011FFFFFF00FFFFFF00FFFFFF000101018901010100010101000101 - 0100010101000101010001010100010101000101010001010133010101CC0000 - 003401010145FFFFFF00FFFFFF00FFFFFF000101011401010100010101000101 - 0100010101000101010001010100010101000101010001010100010101360000 - 00D901010138FFFFFF00FFFFFF00FFFFFF000101017B01010115010101A40101 - 0115010101A401010115010101A401010115010101A401010115010101540101 - 0139000000ACFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0034B4D9D05EC2E1FA60C3E2FA60C3 + E2FA60C3E2FA5FC3E2FA3CB6DBDD2CB2D8162CB2D80F2CB2D80F2CB2D80F2CB2 + D80F2CB3D80F2CB3D804FFFFFF00FFFFFF0036B3DAF8FDFEFEFFFEFFFFFFFEFE + FFFFFDFEFFFFFEFFFFFFEAF7FBFF6BC7E4F96BC7E3F86BC7E3F86BC7E3F879CD + E6F774CAE5E132B1D956FFFFFF00FFFFFF0035AFDAF0F7FCFEFF8EE4F8FF91DE + F5FF9FE0F5FFACE1F6FFEFFBFEFFF4FDFEFFF3FCFEFFF1FCFEFFEFFBFEFFEEFB + FEFFFAFDFFF936AFDAD4FFFFFF00FFFFFF0036AADAF2F1FAFDFF94DEF5FF93DC + F4FF81D5F2FF6ACAEDFF6CCBEAFF85D3EFFF80D2EFFF7AD0EFFF76CFEEFF72CF + EEFFE9F7FBFF34AEDAF3FFFFFF00FFFFFF0035ABDAFAE8F6FBFF94D4EFFF88CE + EEFF73C1E9FFC9E9F6FFF2FCFEFFF3FCFEFFF2FCFEFFF0FCFEFFEFFBFEFFEEFB + FEFFFEFFFFFF36ABDAF7FFFFFF00FFFFFF0037A6DAFAFEFFFFFFF8FDFFFFF6FD + FFFFF5FCFFFFF3FCFEFFD8F6FCFF94E6F8FF85E3F7FF76DFF6FF68DBF5FF5CD8 + F4FFD7F4FCFF35A4DAF7FFFFFF00FFFFFF0036A1DAF9F6FCFEFFC8F2FCFFB9EF + FBFFACECFAFF9CE8F9FF8BE3F7FF7CE0F6FF6CDCF6FF5DD9F5FF4FD6F4FF44D3 + F3FFD0F3FCFF359FDAF7FFFFFF00FFFFFF00369ADAF8F2FAFDFFB3EDFAFFA4E9 + F9FF95E6F8FF85E2F7FF76DEF6FF65DBF5FF57D7F4FF49D4F3FF3BD1F2FF30CE + F1FFCCF2FBFF3598DAF7FFFFFF00FFFFFF003594DAF7EFFAFEFFA1E9F9FF91E5 + F8FF81E1F7FF72DEF6FF63DAF5FF54D7F4FF47D3F3FF39D0F2FF2ECDF1FF26CB + F0FFCAF2FBFF3594DAF7FFFFFF00FFFFFF00338ED9E6DCF0FAF0A7DDF4FD9EDB + F4FF96DAF3FF8ED8F3FF86D7F3FF7FD4F2FF79D3F2FF72D2F1FF6CD0F1FF69CF + F1FFC2EAF8FE338ED9F0FFFFFF00FFFFFF002C86D8702D88D8A62D87D8EA2D88 + D8F72D88D8F72D88D8F72D88D8F72D88D8F72D88D8F72D88D8F72D88D8F72D87 + D8F72D88D8F12C86D893FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00BC6B3671BC6B3690BC6B36CCBC6B36EEBC6B + 36FABB6B36FEBB6B36FFBB6A36FFBB6A36FFBC6C39FFBD6E3BFFBB6D3AFFBB6B + 38EFBB703ECBB6693554FFFFFF00BC6B369BF6E0D1FFF7E0D1FFFEFBF8FFFEFB + F7FFFDF9F6FFFCF5F0FFFAF0EAFFFBF2EDFFFDF9F6FFFDFAF7FFFBF1EBFFF8E9 + DFFEECD0BDFBC9895EECB5693563BC6B36D8F6DFD1FFE9AA80FFFEFAF6FFFDFA + F6FFC88C64FFFBF3EEFFFBF1EAFFFCF6F2FFFEFBF8FFFCF6F1FFF9ECE2FFF8E7 + DBFFEED0BAFFECD0BDFFBB703EF8BC6B36F0F6DFD0FFE8A87EFFFCF6F1FFFCF6 + F1FFC88C64FFFAF1E9FFFBF4EEFFFDFAF7FFFDF9F6FFFAF0E8FFF8E8DDFFF7E6 + DBFFE1A37AFFEFD5C3FFB76935FEBC6B36FAF5DDCCFFE7A87EFFFAF0E8FFFAF0 + E8FFC98D66FFFAF0E9FFFDF8F3FFFEFAF8FFFCF4EFFFF9E9DFFFF7E7DBFFF7E5 + D9FFE0A278FFE7C2A9FFB66835FFBB6B36FEF4DCC9FFE7A77DFFF9ECE1FFF9EC + E1FFF9EDE3FFFCF4EEFFFDFAF7FFFDF7F3FFFAEDE5FFF7E7DBFFF7E5D9FFF6E5 + D8FFDEA077FFE4BEA4FFB46734FFBB6B36FFF4D9C7FFE6A67DFFC88C64FFC98D + 65FFC98E67FFCB926CFFCB926DFFCA9069FFC88C65FFC88C64FFC88C64FFC88C + 64FFDA9C74FFE1BA9FFFB36634FFBB6A36FFF2D8C5FFE3A47BFFE3A37AFFE3A4 + 7AFFE2A47BFFE2A37BFFE1A37BFFE1A279FFDFA077FFDE9F76FFDD9E74FFDB9C + 72FFDC9D74FFDDB59AFFB16534FFBB6A36FFF2D5C2FFE3A37AFFE3A37AFFE2A3 + 7BFFE2A37BFFE2A47BFFE1A279FFE0A178FFDEA077FFDE9E75FFDC9D74FFDA9B + 73FFD99B73FFDAB095FFAF6433FFBB6A36FFF0D2BEFFE2A37AFFE2A37AFFE1A3 + 7AFFE2A37BFFE1A37BFFE0A178FFDE9F77FFDD9F76FFDC9D74FFD99B72FFD899 + 71FFD69970FFD5AB8EFFAD6333FFBA6A36FFEFD0BBFFE2A27AFFFEFBF8FFFEFB + F8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFB + F8FFD3966DFFD2A78AFFAB6232FFBB6B38FFEFCEB8FFE1A279FFFEFAF7FF62C0 + 88FF62C088FF62C088FF62C088FF62C088FF62C088FF62C088FF62C088FFFDF9 + F6FFCF936AFFCEA384FFAA6132FFBB6C38FFEECCB6FFE1A27AFFFEFAF7FFBFDC + C2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFBFDCC2FFFDF9 + F6FFCD9068FFCC9E81FFA86132FFBA6B37FEEDCAB3FFE0A27AFFFEFAF7FF62C0 + 88FF62C088FF62C088FF62C088FF62C088FF62C088FF62C088FF62C088FFFDF9 + F6FFCA8D65FFC99B7CFFA76031FEBA6A35DEEBC6ADFFEAC5ADFFFEFBF8FFFEFB + F8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFBF8FFFEFB + F8FFC89A7CFFC79879FFA76031EDBA6A3600B96935B5B86935EEB76835FFB568 + 35FFB46734FFB26634FFB06533FFAE6433FFAC6332FFAA6232FFA96132FFA860 + 31FFA76031FEA66031F1A86131C4FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00016395000163940001629300016192000162 + 930001629300016394000000000001334C00016597000164960001639400003A + 8C00003E9248003C8FCC00378A48016395000163940001629300016192000162 + 930001629300016394000000000001334C390165969C0164959C0163943E0039 + 8B48003688CC5285C9FF002E7ECC016395000163940001629300016192000162 + 93000162930001639400000000240000006788CCDDFF87CBDDFF016091AF0030 + 80CC3F72B6FF002774CC00247048016395000163940001629300016192000162 + 9300016293100162936D00000069DDDCDCFF949494FF70B4D6FF80C4DBFF015C + 8DB2001A63CC0013584800226E00016395050163941401629328016192410161 + 9277106C9AAB4B9BBADB79B9D5FC919191FFD9D4D4FF8D8D8DFF68ACCEFF74B8 + D4FF015887B4015686400155840001629383126D9BB82078A2C33385ABD058A2 + C0E774B9D1FB6EACCCFF669DC8FF83C7DAFF888888FFD3CACAFF838383FF60A4 + C6FF63A7C9FF015382A5015281000160913E015E8FB16AAEC9FF66A8C5FF5692 + B8FF4B80AFFF5D97BFFF77B9D2FF669DC8FF7BBAD5FF7E7E7EFFCEC0C0FF7979 + 79FF5588BBFF014F7EA6014E7D00015F9000002B5548002B55CC336898FF508C + B3FF69ABC8FF67A7C6FF4D80B3FF71B1CEFF6EA9CDFF6CA3CEFF6D6D6DFFAA99 + 99FF010101A5014C7A42014B7A00015F9000002B55000157873F015585B65FA1 + C0FF3F79A3FF4278A7FF66A6C5FF619DC2FF5E95C1FF74B4D1FF6598CBFF0101 + 01AB0101013C014B7900014B7A00015F9000002B550001568600002B5548002B + 55CC4F8DB3FF68ACC8FF4880ACFF5087B3FF6AAAC8FF5588BBFF00416EC1003E + 6A4401010100014B7900014B7A00015F9000002B550001568600002B5500014D + 7C41014B79BB3A719FFF386F9DFF5F9FC0FF4578ABFF003763C600356046003C + 680001010100014B7900014B7A00015F9000002B550001568600002B5500014C + 7B00002B5548002B55CC5494B7FF34679AFF00305ACA002D584800335E00003C + 680001010100014B7900014B7A00015F9000002B550001568600002B5500014C + 7B00002B550000315C47002D57CC002C56CC002B5548002C570000335E00003C + 680001010100014B7900014B7A00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF @@ -3457,6 +3613,38 @@ object Form1: TForm1 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101810101012B000000330000 + 000D000000670000000D000000670000000D000000670000000D000000670000 + 000D0000004DFFFFFF00FFFFFF00FFFFFF000101012C010101AE0101012C0101 + 0100000000000000000000000000000000000000000000000000000000000000 + 00000000000DFFFFFF00FFFFFF00FFFFFF00000000360101012C010101B00101 + 012C010101000101010000000000000000000000000000000000000000000000 + 00000000006BFFFFFF00FFFFFF00FFFFFF000000000E010101000101012D0101 + 01B30101012D0101010001010100010101000000000000000000000000000000 + 00000000000EFFFFFF00FFFFFF00FFFFFF000000007100000000010101000101 + 012E010101B60101012E01010100010101000101010000000000000000000000 + 000000000071FFFFFF00FFFFFF00FFFFFF000000000F00000000010101000101 + 01000101012E010101B90101012F010101000101010001010100000000000000 + 00000000000FFFFFFF00FFFFFF00FFFFFF000000007800000000000000000101 + 0100010101000101012F010101BC010101300101010001010100000000000000 + 000000000078FFFFFF00FFFFFF00FFFFFF000000001000000000000000000101 + 0100010101000101010001010130010101C00101013101010100010101000000 + 000000000010FFFFFF00FFFFFF00FFFFFF000000008000000000000000000000 + 000001010100010101000101010001010131010101C401010132010101000000 + 000000000080FFFFFF00FFFFFF00FFFFFF000000001100000000010101000101 + 01000101010001010100010101000101010001010132010101C7010101320000 + 000000000011FFFFFF00FFFFFF00FFFFFF000101018901010100010101000101 + 0100010101000101010001010100010101000101010001010133010101CC0000 + 003401010145FFFFFF00FFFFFF00FFFFFF000101011401010100010101000101 + 0100010101000101010001010100010101000101010001010100010101360000 + 00D901010138FFFFFF00FFFFFF00FFFFFF000101017B01010115010101A40101 + 0115010101A401010115010101A401010115010101A401010115010101540101 + 0139000000ACFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF @@ -3487,38 +3675,6 @@ object Form1: TForm1 FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00016395000163940001629300016192000162 - 930001629300016394000000000001334C00016597000164960001639400003A - 8C00003E9248003C8FCC00378A48016395000163940001629300016192000162 - 930001629300016394000000000001334C390165969C0164959C0163943E0039 - 8B48003688CC5285C9FF002E7ECC016395000163940001629300016192000162 - 93000162930001639400000000240000006788CCDDFF87CBDDFF016091AF0030 - 80CC3F72B6FF002774CC00247048016395000163940001629300016192000162 - 9300016293100162936D00000069DDDCDCFF949494FF70B4D6FF80C4DBFF015C - 8DB2001A63CC0013584800226E00016395050163941401629328016192410161 - 9277106C9AAB4B9BBADB79B9D5FC919191FFD9D4D4FF8D8D8DFF68ACCEFF74B8 - D4FF015887B4015686400155840001629383126D9BB82078A2C33385ABD058A2 - C0E774B9D1FB6EACCCFF669DC8FF83C7DAFF888888FFD3CACAFF838383FF60A4 - C6FF63A7C9FF015382A5015281000160913E015E8FB16AAEC9FF66A8C5FF5692 - B8FF4B80AFFF5D97BFFF77B9D2FF669DC8FF7BBAD5FF7E7E7EFFCEC0C0FF7979 - 79FF5588BBFF014F7EA6014E7D00015F9000002B5548002B55CC336898FF508C - B3FF69ABC8FF67A7C6FF4D80B3FF71B1CEFF6EA9CDFF6CA3CEFF6D6D6DFFAA99 - 99FF010101A5014C7A42014B7A00015F9000002B55000157873F015585B65FA1 - C0FF3F79A3FF4278A7FF66A6C5FF619DC2FF5E95C1FF74B4D1FF6598CBFF0101 - 01AB0101013C014B7900014B7A00015F9000002B550001568600002B5548002B - 55CC4F8DB3FF68ACC8FF4880ACFF5087B3FF6AAAC8FF5588BBFF00416EC1003E - 6A4401010100014B7900014B7A00015F9000002B550001568600002B5500014D - 7C41014B79BB3A719FFF386F9DFF5F9FC0FF4578ABFF003763C600356046003C - 680001010100014B7900014B7A00015F9000002B550001568600002B5500014C - 7B00002B5548002B55CC5494B7FF34679AFF00305ACA002D584800335E00003C - 680001010100014B7900014B7A00015F9000002B550001568600002B5500014C - 7B00002B550000315C47002D57CC002C56CC002B5548002C570000335E00003C - 680001010100014B7900014B7A00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF - FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF FF00FFFFFF00FFFFFF00FFFFFF00000000000000000000000000000000000000 000001535F0001A6BE0001A6BE0051515100515151000101E5000101E5160101 D1000000B3000000B3000000B300000000000000000000000000003E530001A6 @@ -3655,6 +3811,15 @@ object Form1: TForm1 top = 376 object MnuFile: TMenuItem Caption = 'File' + object MenuItem50: TMenuItem + Action = AcFileOpen + end + object MenuItem51: TMenuItem + Action = AcFileSaveAs + end + object MenuItem49: TMenuItem + Caption = '-' + end object MenuItem1: TMenuItem Action = AcFileExit end @@ -3709,6 +3874,13 @@ object Form1: TForm1 end end end + object MnuView: TMenuItem + Caption = 'View' + object MenuItem52: TMenuItem + Action = AcViewInspector + AutoCheck = True + end + end end object PuNumFormat: TPopupMenu left = 504 diff --git a/components/fpspreadsheet/examples/fpsctrls/main.pas b/components/fpspreadsheet/examples/fpsctrls/main.pas index fdcc734fa..f510ec7c7 100644 --- a/components/fpspreadsheet/examples/fpsctrls/main.pas +++ b/components/fpspreadsheet/examples/fpsctrls/main.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, - StdCtrls, ComCtrls, ActnList, Menus, StdActns, + ComCtrls, ActnList, Menus, StdActns, fpspreadsheet, fpspreadsheetctrls, fpspreadsheetgrid, fpsActions; type @@ -14,9 +14,11 @@ type { TForm1 } TForm1 = class(TForm) + AcViewInspector: TAction; ActionList: TActionList; - Button1: TButton; AcFileExit: TFileExit; + AcFileOpen: TFileOpen; + AcFileSaveAs: TFileSaveAs; ImageList: TImageList; MainMenu: TMainMenu; MenuItem1: TMenuItem; @@ -62,7 +64,12 @@ type MenuItem46: TMenuItem; MenuItem47: TMenuItem; MenuItem48: TMenuItem; + MenuItem49: TMenuItem; MenuItem5: TMenuItem; + MenuItem50: TMenuItem; + MenuItem51: TMenuItem; + MenuItem52: TMenuItem; + MnuView: TMenuItem; MenuItem6: TMenuItem; MenuItem7: TMenuItem; MenuItem8: TMenuItem; @@ -73,7 +80,6 @@ type MnuEdit: TMenuItem; OpenDialog: TOpenDialog; OpenDialog1: TOpenDialog; - Panel1: TPanel; CellEdit: TsCellEdit; CellIndicator: TsCellIndicator; AcFontBold: TsFontStyleAction; @@ -94,6 +100,7 @@ type AcNumFormatPercentage: TsNumberFormatAction; AcNumFormatCurrency: TsNumberFormatAction; AcNumFormatCurrencyRed: TsNumberFormatAction; + Panel2: TPanel; PuBorders: TPopupMenu; PuTimeFormat: TPopupMenu; PuDateFormat: TPopupMenu; @@ -130,9 +137,13 @@ type AcCellBorderAll: TsCellBorderAction; AcCellBorderAllVert: TsCellBorderAction; FontnameCombo: TsFontnameCombobox; + AcCopyFormat: TsCopyFormatAction; sFontSizeCombobox1: TsFontSizeCombobox; AcMergeCells: TsMergeAction; + Splitter2: TSplitter; + Splitter3: TSplitter; ToolBar2: TToolBar; + ToolBar3: TToolBar; ToolButton1: TToolButton; ToolButton11: TToolButton; ToolButton12: TToolButton; @@ -162,6 +173,7 @@ type ToolButton25: TToolButton; ToolButton26: TToolButton; ToolButton27: TToolButton; + ToolButton28: TToolButton; ToolButton29: TToolButton; ToolButton3: TToolButton; ToolButton30: TToolButton; @@ -170,15 +182,22 @@ type ToolButton32: TToolButton; ToolButton33: TToolButton; ToolButton34: TToolButton; + ToolButton35: TToolButton; + ToolButton36: TToolButton; + ToolButton37: TToolButton; + ToolButton38: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; + ToolButton9: TToolButton; WorkbookSource: TsWorkbookSource; WorkbookTabControl: TsWorkbookTabControl; WorksheetGrid: TsWorksheetGrid; - procedure Button1Click(Sender: TObject); + procedure AcFileOpenAccept(Sender: TObject); + procedure AcFileSaveAsAccept(Sender: TObject); + procedure AcViewInspectorExecute(Sender: TObject); procedure InspectorTabControlChange(Sender: TObject); private { private declarations } @@ -195,24 +214,53 @@ implementation { TForm1 } -procedure TForm1.Button1Click(Sender: TObject); +{ Loads the spreadsheet file selected by the AcFileOpen action } +procedure TForm1.AcFileOpenAccept(Sender: TObject); begin - if OpenDialog.Execute then begin - WorkbookSource.AutodetectFormat := false; - case OpenDialog.FilterIndex of - 1: WorkbookSource.AutoDetectFormat := true; // All spreadsheet files - 2: WorkbookSource.AutoDetectFormat := true; // All Excel files - 3: WorkbookSource.FileFormat := sfOOXML; // Excel 2007+ - 4: WorkbookSource.FileFormat := sfExcel8; // Excel 97-2003 - 5: WorkbookSource.FileFormat := sfExcel5; // Excel 5.0 - 6: WorkbookSource.FileFormat := sfExcel2; // Excel 2.1 - 7: WorkbookSource.FileFormat := sfOpenDocument; // Open/LibreOffice - 8: WorkbookSource.FileFormat := sfCSV; // Text files + WorkbookSource.AutodetectFormat := false; + case AcFileOpen.Dialog.FilterIndex of + 1: WorkbookSource.AutoDetectFormat := true; // All spreadsheet files + 2: WorkbookSource.AutoDetectFormat := true; // All Excel files + 3: WorkbookSource.FileFormat := sfOOXML; // Excel 2007+ + 4: WorkbookSource.FileFormat := sfExcel8; // Excel 97-2003 + 5: WorkbookSource.FileFormat := sfExcel5; // Excel 5.0 + 6: WorkbookSource.FileFormat := sfExcel2; // Excel 2.1 + 7: WorkbookSource.FileFormat := sfOpenDocument; // Open/LibreOffice + 8: WorkbookSource.FileFormat := sfCSV; // Text files + end; + WorkbookSource.FileName := AcFileOpen.Dialog.FileName; // this loads the file +end; + +{ Saves the spreadsheet to the file selected by the AcFileSaveAs action } +procedure TForm1.AcFileSaveAsAccept(Sender: TObject); +var + fmt: TsSpreadsheetFormat; +begin + Screen.Cursor := crHourglass; + try + case AcFileSaveAs.Dialog.FilterIndex of + 1: fmt := sfOOXML; + 2: fmt := sfExcel8; + 3: fmt := sfExcel5; + 4: fmt := sfExcel2; + 5: fmt := sfOpenDocument; + 6: fmt := sfCSV; + 7: fmt := sfWikiTable_WikiMedia; end; - WorkbookSource.FileName := OpenDialog.FileName; // this loads the file + WorkbookSource.SaveToSpreadsheetFile(AcFileSaveAs.Dialog.FileName, fmt); + finally + Screen.Cursor := crDefault; end; end; +{ Toggles the spreadsheet inspector on and off } +procedure TForm1.AcViewInspectorExecute(Sender: TObject); +begin + InspectorTabControl.Visible := AcViewInspector.Checked; +end; + +{ Event handler to synchronize the mode of the spreadsheet inspector with the + selected tab of the TabControl } procedure TForm1.InspectorTabControlChange(Sender: TObject); begin Inspector.Mode := TsInspectorMode(InspectorTabControl.TabIndex); diff --git a/components/fpspreadsheet/fpsactions.pas b/components/fpspreadsheet/fpsactions.pas index 363659d40..c867ef47f 100644 --- a/components/fpspreadsheet/fpsactions.pas +++ b/components/fpspreadsheet/fpsactions.pas @@ -117,6 +117,28 @@ type property Worksheet; end; + TsCopyFormatAction = class(TsSpreadsheetAction) + private + FSource: TsCellRange; + public + procedure ExecuteTarget(Target: TObject); override; + procedure UpdateTarget(Target: TObject); override; + published + property Caption; + property Enabled; + property HelpContext; + property HelpKeyword; + property HelpType; + property Hint; + property ImageIndex; + property OnExecute; + property OnHint; + property OnUpdate; + property SecondaryShortCuts; + property ShortCut; + property Visible; + end; + TsAutoFormatAction = class(TsCellAction) public procedure ExecuteTarget(Target: TObject); override; @@ -442,6 +464,7 @@ begin // Worksheet-releated actions TsWorksheetAddAction, TsWorksheetDeleteAction, TsWorksheetRenameAction, // Cell or cell range formatting actions + TsCopyFormatAction, TsFontStyleAction, TsFontDialogAction, TsBackgroundColorDialogAction, TsHorAlignmentAction, TsVertAlignmentAction, TsTextRotationAction, TsWordWrapAction, @@ -690,6 +713,41 @@ begin end; +{ TsCopyFormatAction } + +procedure TsCopyFormatAction.ExecuteTarget(Target: TObject); +var + srcRow, srcCol: Cardinal; // Row and column index of source cell + destRow, destCol: Cardinal; // Row and column index of destination cell + srcCell, destCell: PCell; // Pointers to source and destination cells +begin + if (FSource.Row1 = Cardinal(-1)) or (FSource.Row2 = Cardinal(-1)) or + (FSource.Col1 = Cardinal(-1)) or (FSource.Col2 = Cardinal(-1)) + then + exit; + + for srcRow := FSource.Row1 to FSource.Row2 do + begin + destRow := Worksheet.ActiveCellRow + srcRow - FSource.Row1; + for srcCol := FSource.Col1 to FSource.Col2 do begin + destCol := Worksheet.ActiveCellCol + srcCol - FSource.Col1; + srcCell := Worksheet.FindCell(srcRow, srcCol); + destCell := Worksheet.FindCell(destRow, destCol); + Worksheet.CopyFormat(srcCell, destCell); + end; + end; +end; + +procedure TsCopyFormatAction.UpdateTarget(Target: TObject); +begin + if (Worksheet = nil) or (Worksheet.GetSelectionCount = 0) then + FSource := TsCellRange(Rect(-1, -1, -1,-1)) + else + FSource := Worksheet.GetSelection[0]; + // Memorize current selection - it will be the source of the copy format operation. +end; + + { TsAutoFormatAction - action for cell formatting which is automatically updated according to the current selection } diff --git a/components/fpspreadsheet/fpspreadsheetctrls.pas b/components/fpspreadsheet/fpspreadsheetctrls.pas index 340f98448..a929871bf 100644 --- a/components/fpspreadsheet/fpspreadsheetctrls.pas +++ b/components/fpspreadsheet/fpspreadsheetctrls.pas @@ -489,8 +489,6 @@ end; procedure TsWorkbookSource.InternalLoadFromFile(AFileName: string; AAutoDetect: Boolean; AFormat: TsSpreadsheetFormat; AWorksheetIndex: Integer = 0); begin - Unused(AWorksheetIndex); - // Create a new empty workbook InternalCreateNewWorkbook; @@ -649,8 +647,13 @@ end; procedure TsWorkbookSource.SaveToSpreadsheetFile(AFileName: String; AFormat: TsSpreadsheetFormat; AOverwriteExisting: Boolean = true); begin - if Workbook <> nil then - Workbook.WriteToFile(AFileName, AFormat, AOverwriteExisting); + if FWorkbook <> nil then begin + FWorkbook.WriteToFile(AFileName, AFormat, AOverwriteExisting); + + // If required, display loading error message + if FWorkbook.ErrorMsg <> '' then + DoShowError(FWorkbook.ErrorMsg); + end; end; {@@ ---------------------------------------------------------------------------- @@ -670,8 +673,13 @@ end; procedure TsWorkbookSource.SaveToSpreadsheetFile(AFileName: String; AOverwriteExisting: Boolean = true); begin - if Workbook <> nil then - Workbook.WriteToFile(AFileName, AOverwriteExisting); + if FWorkbook <> nil then begin + FWorkbook.WriteToFile(AFileName, AOverwriteExisting); + + // If required, display loading error message + if FWorkbook.ErrorMsg <> '' then + DoShowError(FWorkbook.ErrorMsg); + end; end; {@@ ----------------------------------------------------------------------------