📄 ufrm_ysbzjpx_pxjh.~pas
字号:
unit uFrm_Ysbzjpx_pxjh;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxControls, cxSSheet, RzButton, ComCtrls, ImgList, Menus,
StdActns, ActnList, StdCtrls, ExtCtrls, ToolWin,cxSSTypes,
DBTables, DB, ADODB, DBCtrls,cxSSUtils,cxSSRes, dxPSCore,
dxPSBaseGridLnk, dxPScxSSLnk;
type
TStyleValue = (svAlign, svFontName, svSize, svBold, svItalic, svUnderline, svStrikeOut);
TStyleValueSet = set of TStyleValue;
TFrm_ysbZjpx_pxjh = class(TForm)
cbMain: TControlBar;
tbsFormatting: TToolBar;
cbxFont: TComboBox;
cbxSize: TComboBox;
ToolButton9: TToolButton;
tbLeftAlign: TToolButton;
tbCenterAlign: TToolButton;
tbRightAlign: TToolButton;
ToolButton10: TToolButton;
tbBold: TToolButton;
tbItalic: TToolButton;
tbUnderline: TToolButton;
tbStrikeOut: TToolButton;
ToolButton11: TToolButton;
tbMerge: TToolButton;
tgSplit: TToolButton;
ToolButton16: TToolButton;
tbSummary: TToolButton;
tbSortAscending: TToolButton;
tbSortDescending: TToolButton;
ToolButton18: TToolButton;
tbBorderStyle: TToolButton;
tbsStandart: TToolBar;
tbsNew: TToolButton;
tbsOpen: TToolButton;
tbsSave: TToolButton;
ToolButton7: TToolButton;
tbsCut: TToolButton;
tbsCopy: TToolButton;
tbsPaste: TToolButton;
tlbHistory: TToolBar;
tbUndo: TToolButton;
ToolButton1: TToolButton;
pnCell: TPanel;
edtCellEdit: TEdit;
pnCellText: TPanel;
pnCellRect: TPanel;
alMain: TActionList;
actNew: TAction;
actDeleteCells: TAction;
actOpenSpreadSheet: TAction;
actSaveSpeadSheet: TAction;
actInsertCells: TAction;
actExit: TAction;
actAutomaticCalc: TAction;
actRecalcFormulas: TAction;
actCut: TAction;
actCopy: TAction;
actPaste: TAction;
actBeveledLookandFeel: TAction;
actBufferedpaint: TAction;
actShowcaptions: TAction;
actShowgrid: TAction;
actShowheaders: TAction;
actShowformulas: TAction;
actR1C1Referencestyle: TAction;
actCells: TAction;
actRow: TAction;
actColumn: TAction;
actSheet: TAction;
actWindowClose: TWindowClose;
actWindowCascade: TWindowCascade;
actWindowTileHorizontal: TWindowTileHorizontal;
actWindowTileVertical: TWindowTileVertical;
actWindowMinimizeAll: TWindowMinimizeAll;
actWindowArrange: TWindowArrange;
actCellLeftAlign: TAction;
actCellRightAlign: TAction;
actCellCenterAlign: TAction;
actBold: TAction;
actItalic: TAction;
actUnderline: TAction;
actStrikeOut: TAction;
actMergeCells: TAction;
actSplitCells: TAction;
actSortAscending: TAction;
actSortDescending: TAction;
actSum: TAction;
actFont: TAction;
actFontSize: TAction;
actAverage: TAction;
actCount: TAction;
actMax: TAction;
actMin: TAction;
actFormatCells: TAction;
actHideCells: TAction;
actShowCells: TAction;
actHideCol: TAction;
actShowCol: TAction;
actHideRow: TAction;
actShowRow: TAction;
actUndo: TAction;
actRedo: TAction;
mnuMain: TMainMenu;
mnuFile: TMenuItem;
miNew: TMenuItem;
N2: TMenuItem;
miOpenSpreadSheet: TMenuItem;
miSaveSpreadSheet: TMenuItem;
N1: TMenuItem;
miExit: TMenuItem;
mnuEdit: TMenuItem;
miAutomaticcalculation: TMenuItem;
miRecalcformulas: TMenuItem;
N3: TMenuItem;
miCut: TMenuItem;
miCopy: TMenuItem;
miPaste: TMenuItem;
N7: TMenuItem;
miCells: TMenuItem;
miFormat: TMenuItem;
miHide: TMenuItem;
miShow: TMenuItem;
miDeletecells: TMenuItem;
Insertcells1: TMenuItem;
miColumns: TMenuItem;
Hide2: TMenuItem;
Show2: TMenuItem;
miRows: TMenuItem;
Hide3: TMenuItem;
Show3: TMenuItem;
mnuInsert: TMenuItem;
miCells1: TMenuItem;
miRow: TMenuItem;
miColumn: TMenuItem;
N12: TMenuItem;
miSheet: TMenuItem;
mnuConfig: TMenuItem;
miBeveledLookandFeel: TMenuItem;
miBufferedpaint: TMenuItem;
N4: TMenuItem;
miShowcaptions: TMenuItem;
miShowgrid: TMenuItem;
miShowheaders: TMenuItem;
miShowformulas: TMenuItem;
N5: TMenuItem;
miR1C1Referencestyle: TMenuItem;
pmSheetPopup: TPopupMenu;
pmiCut: TMenuItem;
pmiCopy: TMenuItem;
pmiPaste: TMenuItem;
N6: TMenuItem;
actMerge1: TMenuItem;
actSplitCells1: TMenuItem;
N9: TMenuItem;
pmiDelete: TMenuItem;
pmiInsert: TMenuItem;
N10: TMenuItem;
pmiCols: TMenuItem;
pmiColsHide: TMenuItem;
pmiColsShow: TMenuItem;
pmiRows: TMenuItem;
pmiRowsHide: TMenuItem;
pmiRowsShow: TMenuItem;
Show1: TMenuItem;
Hide1: TMenuItem;
pmiFormatCells: TMenuItem;
pmSummary: TPopupMenu;
Sum1: TMenuItem;
Average1: TMenuItem;
Count1: TMenuItem;
Max1: TMenuItem;
Min1: TMenuItem;
pmBorders: TPopupMenu;
N11: TMenuItem;
N21: TMenuItem;
N31: TMenuItem;
N41: TMenuItem;
N51: TMenuItem;
N61: TMenuItem;
N71: TMenuItem;
N81: TMenuItem;
N91: TMenuItem;
N101: TMenuItem;
N111: TMenuItem;
N121: TMenuItem;
imgFormatting: TImageList;
imgBordersImages: TImageList;
imgStandart: TImageList;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
pmRedo: TPopupMenu;
pmUndo: TPopupMenu;
imgHistory: TImageList;
Panel1: TPanel;
DateTimePicker1: TDateTimePicker;
RzBitBtn1: TRzBitBtn;
cxSpreadBook: TcxSpreadSheetBook;
Action1: TAction;
N8: TMenuItem;
actSaveAsSpeadSheet: TAction;
ToolButton2: TToolButton;
dxComponentPrinter1: TdxComponentPrinter;
dxComponentPrinter1Link1: TdxSpreadSheetBookReportLink;
actPrint: TAction;
N13: TMenuItem;
procedure cxSpreadBookSetSelection(Sender: TObject;
ASheet: TcxSSBookSheet);
procedure edtCellEditExit(Sender: TObject);
procedure edtCellEditKeyPress(Sender: TObject; var Key: Char);
procedure cxSpreadBookEditing(Sender: TcxSSBookSheet; const ACol,
ARow: Integer; var CanEdit: Boolean);
procedure cxSpreadBookEndEdit(Sender: TObject);
procedure cxSpreadBookContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
procedure edtCellEditChange(Sender: TObject);
procedure cxSpreadBookSheetPopupMenu(Sender: TObject; X, Y: Integer);
procedure cxSpreadBookActiveSheetChanging(
Sender: TcxCustomSpreadSheetBook; const ActiveSheet: Integer;
var CanSelect: Boolean);
procedure miSaveSpreadSheetClick(Sender: TObject);
procedure Action1Execute(Sender: TObject);
procedure actSaveSpeadSheetExecute(Sender: TObject);
procedure actSaveAsSpeadSheetExecute(Sender: TObject);
procedure RzBitBtn1Click(Sender: TObject);
procedure actNewExecute(Sender: TObject);
procedure actMergeCellsExecute(Sender: TObject);
procedure actSplitCellsExecute(Sender: TObject);
procedure actCellLeftAlignExecute(Sender: TObject);
procedure SetCellsStyle(AValuesSet: TStyleValueSet; AAlign: TcxHorzTextAlign;
AFontSize: Integer; const AFontName: string; AStyles: TFontStyles);
procedure actCellRightAlignExecute(Sender: TObject);
procedure actCellCenterAlignExecute(Sender: TObject);
procedure actDeleteCellsExecute(Sender: TObject);
procedure actInsertCellsExecute(Sender: TObject);
procedure actFormatCellsExecute(Sender: TObject);
procedure actHideCellsExecute(Sender: TObject);
procedure actShowCellsExecute(Sender: TObject);
procedure actHideColExecute(Sender: TObject);
procedure actShowColExecute(Sender: TObject);
procedure actBeveledLookandFeelExecute(Sender: TObject);
procedure actBufferedpaintExecute(Sender: TObject);
procedure actShowcaptionsExecute(Sender: TObject);
procedure actShowgridExecute(Sender: TObject);
procedure actShowheadersExecute(Sender: TObject);
procedure actShowformulasExecute(Sender: TObject);
procedure actR1C1ReferencestyleExecute(Sender: TObject);
procedure actAutomaticCalcExecute(Sender: TObject);
procedure actRecalcFormulasExecute(Sender: TObject);
procedure actCutExecute(Sender: TObject);
procedure actCopyExecute(Sender: TObject);
procedure actPasteExecute(Sender: TObject);
procedure actUndoExecute(Sender: TObject);
procedure actRedoExecute(Sender: TObject);
procedure actCellsExecute(Sender: TObject);
procedure actRowExecute(Sender: TObject);
procedure actColumnExecute(Sender: TObject);
procedure actSheetExecute(Sender: TObject);
procedure actFontExecute(Sender: TObject);
procedure actFontSizeExecute(Sender: TObject);
procedure actHideRowExecute(Sender: TObject);
procedure actShowRowExecute(Sender: TObject);
procedure actSortAscendingExecute(Sender: TObject);
procedure actSortDescendingExecute(Sender: TObject);
procedure actSumExecute(Sender: TObject);
procedure actAverageExecute(Sender: TObject);
procedure actCountExecute(Sender: TObject);
procedure actMaxExecute(Sender: TObject);
procedure actMinExecute(Sender: TObject);
procedure actBoldExecute(Sender: TObject);
procedure actItalicExecute(Sender: TObject);
procedure actUnderlineExecute(Sender: TObject);
procedure actStrikeOutExecute(Sender: TObject);
procedure tbBorderStyleClick(Sender: TObject);
procedure mnuBordersDrawItem(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Selected: Boolean);
procedure mnuBordersMeasureItem(Sender: TObject; ACanvas: TCanvas;
var Width, Height: Integer);
procedure mnuBordersClick(Sender: TObject);
procedure cbxFontKeyPress(Sender: TObject; var Key: Char);
procedure cbxSizeKeyPress(Sender: TObject; var Key: Char);
procedure actOpenSpreadSheetExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure actPrintExecute(Sender: TObject);
private
{ Private declarations }
FIsEditorMode: Boolean;
FIsUpdate: Boolean;
FSummaryItemHeight: Integer;
function GetCellText(SelectionRect: TRect; R1C1: Boolean): String;
procedure SetStates;
procedure CalculateSummary(AType: Byte);
procedure SetTokenStyle(AToolButton: TToolButton; AStyleValue: TStyleValue; AFontStyle: TFontStyle);
protected
procedure OpenSpreadSheet;
procedure SaveSpreadSheet;
public
property IsUpdate: Boolean read FIsUpdate write FIsUpdate;
procedure SetSelection;
procedure SaveAsSpreadSheet;
procedure NewSheet(const ASheetName: string = '');
constructor Create(AOwner: TComponent); override;
{ Public declarations }
end;
var
Frm_ysbZjpx_pxjh: TFrm_ysbZjpx_pxjh;
implementation
uses uDm_ysbZjpx_pxjh, uFeatureModifyForm;
{$R *.dfm}
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookEditing(Sender: TcxSSBookSheet;
const ACol, ARow: Integer; var CanEdit: Boolean);
begin
FIsEditorMode := True;
end;
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookEndEdit(Sender: TObject);
begin
FIsEditorMode := False;
end;
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookContextPopup(Sender: TObject;
MousePos: TPoint; var Handled: Boolean);
begin
if (MousePos.X = -1) and (MousePos.Y = -1) then
MousePos := ClientToScreen(Point(0, 0));
self.pmSheetPopup.Popup(MousePos.X, MousePos.Y);
Handled := True;
end;
procedure TFrm_ysbZjpx_pxjh.edtCellEditChange(Sender: TObject);
begin
if FIsUpdate then Exit;
with cxSpreadBook do
begin
with ActiveSheet.GetCellObject(ActiveSheet.SelectionRect.Left, ActiveSheet.SelectionRect.Top) do
SetCellText((Sender as TEdit).Text);
UpdateControl;
end;
end;
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookSheetPopupMenu(Sender: TObject; X,
Y: Integer);
begin
self.pmSheetPopup.Popup(X, Y);
end;
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookActiveSheetChanging(
Sender: TcxCustomSpreadSheetBook; const ActiveSheet: Integer;
var CanSelect: Boolean);
begin
SetSelection;
end;
procedure TFrm_ysbZjpx_pxjh.SetSelection;
begin
if Assigned(cxSpreadBook.OnSetSelection) then
cxSpreadBook.OnSetSelection(cxSpreadBook, cxSpreadBook.ActiveSheet);
end;
procedure TFrm_ysbZjpx_pxjh.cxSpreadBookSetSelection(Sender: TObject;
ASheet: TcxSSBookSheet);
begin
try
FIsUpdate := True;
SetStates;
pnCellRect.Caption := GetCellText(ASheet.SelectionRect, cxSpreadBook.R1C1ReferenceStyle);
finally
FIsUpdate := False;
end;
end;
procedure TFrm_ysbZjpx_pxjh.SetStates;
var
AStyle: TFontStyles;
begin
with cxSpreadBook do
begin
with ActiveSheet.GetCellObject(ActiveSheet.SelectionRect.Left,
ActiveSheet.SelectionRect.Top) do
try
tbLeftAlign.Down := DisplayTextAlignment in [dtaLEFT, dtaFILL, dtaJUSTIFY];
tbCenterAlign.Down := DisplayTextAlignment in [dtaCenter];
tbRightAlign.Down := DisplayTextAlignment in [dtaRight];
AStyle := Style.Font.Style;
tbBold.Down := fsBold in AStyle;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -