⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ufrm_ysbzjpx_pxjh.~pas

📁 运输培训管理束)录像等四个按钮。 [Conferencing_Vidio_system.rar] - 用微软实时通信(RTC)API创建音频和视频会议、共享应用程序、共享白板、简单的点对点聊天对话
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
end;

procedure TFrm_ysbZjpx_pxjh.actCellsExecute(Sender: TObject);
var
  AForm :TFeatureModifyForm;
const
  AFormType: array[Boolean] of TcxSSModifyType = (mtDelete, mtInsert);
begin
   if IsUpdate then Exit;
   AForm := TFeatureModifyForm.Create(Self);
   AForm.Top := (Top + Height) shr 1;
   AForm.Left := (Left + Width) shr 1;
   try
     if AForm.Execute(AFormType[TCustomAction(Sender).Tag = 1]) then
       with cxSpreadBook.ActiveSheet do
         case TCustomAction(Sender).Tag of
           0:
             DeleteCells(SelectionRect, AForm.Modify);
           1:
             InsertCells(SelectionRect, AForm.Modify);
         end;
   finally
     AForm.Free;
   end;
end;


procedure TFrm_ysbZjpx_pxjh.actRowExecute(Sender: TObject);
begin
  with cxSpreadBook do
    ActiveSheet.InsertCells(ActiveSheet.SelectionRect, msAllRow);

end;

procedure TFrm_ysbZjpx_pxjh.actColumnExecute(Sender: TObject);
begin
  with cxSpreadBook do
    ActiveSheet.InsertCells(ActiveSheet.SelectionRect, msAllCol);

end;

procedure TFrm_ysbZjpx_pxjh.actSheetExecute(Sender: TObject);
begin
  with cxSpreadBook do
    PageCount := PageCount + 1;
end;

procedure TFrm_ysbZjpx_pxjh.actFontExecute(Sender: TObject);
begin
  SetCellsStyle([svFontName], haGeneral, 0, cbxFont.Text, []);
end;

procedure TFrm_ysbZjpx_pxjh.actFontSizeExecute(Sender: TObject);
var
  ASize: Integer;
begin
  if cxTryStrToInt(cbxSize.Text, ASize) then
    SetCellsStyle([svSize], haGeneral, ASize, cbxFont.Text, []);
end;


procedure TFrm_ysbZjpx_pxjh.actHideRowExecute(Sender: TObject);
begin
  if IsUpdate then Exit;
  with cxSpreadBook.ActiveSheet do
    SetVisibleState(SelectionRect, False, True, False);

end;

procedure TFrm_ysbZjpx_pxjh.actShowRowExecute(Sender: TObject);
begin
  if IsUpdate then Exit;
  with cxSpreadBook.ActiveSheet do
    SetVisibleState(SelectionRect, False, True, True);

end;

procedure TFrm_ysbZjpx_pxjh.actSortAscendingExecute(Sender: TObject);
const
  ASortType: array[0..1] of TcxSortType = (stAscending, stDescending);
begin
  with cxSpreadBook.ActiveSheet do
    Sort(SelectionRect, [ASortType[TCustomAction(Sender).Tag]]);
end;

procedure TFrm_ysbZjpx_pxjh.actSortDescendingExecute(Sender: TObject);
const
  ASortType: array[0..1] of TcxSortType = (stAscending, stDescending);
begin
  with cxSpreadBook.ActiveSheet do
    Sort(SelectionRect, [ASortType[TCustomAction(Sender).Tag]]);
end;

procedure TFrm_ysbZjpx_pxjh.actSumExecute(Sender: TObject);
begin
  CalculateSummary(TComponent(Sender).Tag);
end;

procedure TFrm_ysbZjpx_pxjh.actAverageExecute(Sender: TObject);
begin
  CalculateSummary(TComponent(Sender).Tag);
end;

procedure TFrm_ysbZjpx_pxjh.actCountExecute(Sender: TObject);
begin
  CalculateSummary(TComponent(Sender).Tag);
end;

procedure TFrm_ysbZjpx_pxjh.actMaxExecute(Sender: TObject);
begin
  CalculateSummary(TComponent(Sender).Tag);
end;

procedure TFrm_ysbZjpx_pxjh.actMinExecute(Sender: TObject);
begin
  CalculateSummary(TComponent(Sender).Tag);
end;

procedure TFrm_ysbZjpx_pxjh.actBoldExecute(Sender: TObject);
begin
  SetTokenStyle(tbBold, svBold, fsBold);
end;

procedure TFrm_ysbZjpx_pxjh.actItalicExecute(Sender: TObject);
begin
  SetTokenStyle(tbItalic, svItalic, fsItalic);
end;

procedure TFrm_ysbZjpx_pxjh.actUnderlineExecute(Sender: TObject);
begin
  SetTokenStyle(tbUnderline, svUnderline, fsUnderline);
end;

procedure TFrm_ysbZjpx_pxjh.actStrikeOutExecute(Sender: TObject);
begin
  SetTokenStyle(tbStrikeOut, svStrikeOut, fsStrikeOut);
end;
procedure TFrm_ysbZjpx_pxjh.CalculateSummary(AType: Byte);

  function SelRect(const ARect: TRect): string;
  begin
    Result := cxSpreadBook.CellsNameByRef(cxSpreadBook.ActivePage, ARect, False);
  end;
var
  S: string;
  ARect: TRect;
  ACell: TcxssCellObject;
const
  AFunc: array[0..4] of string = (sxlfSum, sxlfAverage, sxlfCount, sxlfMax, sxlfMin);
begin
  with cxSpreadBook do
  try
    ARect := SelectionRect;
    S := SelRect(ARect);
    ACell := ActiveSheet.GetCellObject(ARect.Right, ARect.Bottom + 1);
    try
      ACell.Text := '=' + AFunc[AType] + '(' + S + ')';
    finally
      ACell.Free;
    end;
  finally
    UpdateControl;
  end;
end;
procedure TFrm_ysbZjpx_pxjh.SetTokenStyle(AToolButton: TToolButton; AStyleValue: TStyleValue; AFontStyle: TFontStyle);
begin
  if AToolButton.Down then
    SetCellsStyle([AStyleValue], haGeneral, 0, '', [AFontStyle])
  else
    SetCellsStyle([AStyleValue], haGeneral, 0, '', []);
end;

procedure TFrm_ysbZjpx_pxjh.tbBorderStyleClick(Sender: TObject);
var
  ARect: TRect;
begin
  ARect := tbBorderStyle.BoundsRect;
  ARect.TopLeft := tbsFormatting.ClientToScreen(ARect.TopLeft);
  ARect.BottomRight := tbsFormatting.ClientToScreen(ARect.BottomRight);
  tbBorderStyle.Down := True;
  pmBorders.Popup(ARect.Left, ARect.Bottom);
  tbBorderStyle.Down := False;
end;
procedure TFrm_ysbZjpx_pxjh.mnuBordersDrawItem(Sender: TObject; ACanvas: TCanvas;
  ARect: TRect; Selected: Boolean);
begin
  if Selected then
    ACanvas.Brush.Color := clHighLight
  else
    ACanvas.Brush.Color := clMenu;
  ACanvas.Brush.Style := bsSolid;
  ACanvas.FillRect(ARect);
  imgBordersImages.Draw(ACanvas, ARect.Left + 2, ARect.Top + 2, (Sender as TMenuItem).ImageIndex);
end;

procedure TFrm_ysbZjpx_pxjh.mnuBordersMeasureItem(Sender: TObject; ACanvas: TCanvas;
  var Width, Height: Integer);
begin
  Width := 14;
  Height := 24;
end;

procedure TFrm_ysbZjpx_pxjh.mnuBordersClick(Sender: TObject);
var
  ARect: TRect;
  AKey, I: Integer;
const
  AOutBorders: array[0..11, TcxSSEdgeBorder] of TcxSSEdgeLineStyle =
    ((lsDefault, lsDefault, lsDefault, lsDefault),
     (lsNone, lsNone, lsNone, lsDouble),
     (lsNone, lsThin, lsNone, lsThick),
     (lsNone, lsNone, lsNone, lsThin),
     (lsNone, lsNone, lsNone, lsThick),
     (lsThin, lsThin, lsThin, lsThin),
     (lsThin, lsNone, lsNone, lsNone),
     (lsNone, lsThin, lsNone, lsThin),
     (lsThin, lsThin, lsThin, lsThin),
     (lsNone, lsNone, lsThin, lsNone),
     (lsNone, lsThin, lsNone, lsDouble),
     (lsThick, lsThick, lsThick, lsThick));

  AInBorders: array[Boolean] of TcxSSEdgeLineStyle = (lsDefault, lsThin);

  procedure SetHorzStyle(ARow: Integer; AStyle: TcxSSEdgeLineStyle);
  var
    I: Integer;
  begin
    if AStyle <> lsNone then
    begin
      for I := ARect.Left to ARect.Right do
      begin
        with cxSpreadBook.ActiveSheet.GetCellObject(I, ARow) do
        try
          if (AKey = 0) or (AStyle <> lsDefault) then
            Style.Borders[eTop].Style := AStyle;
        finally
          Free;
        end;
      end;
    end;
  end;

  procedure SetVertStyle(ACol: Integer; AStyle: TcxSSEdgeLineStyle);
  var
    I: Integer;
  begin
    if AStyle <> lsNone then
    begin
      for I := ARect.Top to ARect.Bottom do
      begin
        with cxSpreadBook.ActiveSheet.GetCellObject(ACol, I) do
        try
          if (AKey = 0) or (AStyle <> lsDefault) then
            Style.Borders[eLeft].Style := AStyle;
        finally
          Free;
        end;
      end;
    end;
  end;

begin
  cxSpreadBook.BeginUpdate;
  try
    ARect := cxSpreadBook.ActiveSheet.SelectionRect;
    AKey := (Sender as TMenuItem).ImageIndex;
    SetVertStyle(ARect.Left, AOutBorders[AKey, eLeft]);
    SetHorzStyle(ARect.Top, AOutBorders[AKey, eTop]);
    SetVertStyle(ARect.Right + 1, AOutBorders[AKey, eRight]);
    SetHorzStyle(ARect.Bottom + 1, AOutBorders[AKey, eBottom]);
    for I := ARect.Top + 1 to ARect.Bottom do
      SetHorzStyle(I, AInBorders[AKey = 5]);
    for I := ARect.Left + 1 to ARect.Right do
      SetVertStyle(I, AInBorders[AKey = 5]);
  finally
    cxSpreadBook.EndUpdate;
    cxSpreadBook.UpdateControl;
  end;
end;

procedure TFrm_ysbZjpx_pxjh.cbxFontKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = #13 then
    Windows.SetFocus(cxSpreadBook.Handle);
end;

procedure TFrm_ysbZjpx_pxjh.cbxSizeKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = #13 then
    Windows.SetFocus(cxSpreadBook.Handle)
  else
    if not (Key in ['0'..'9']) then
      Key := #0;
end;

constructor TFrm_ysbZjpx_pxjh.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  cbxFont.Items.Assign(Screen.Fonts);
  cbxFont.Text := '宋体';
  cbxSize.Text := '9';
  FSummaryItemHeight := 10;
  {$IFDEF VER140}
  pmRedo.AutoHotkeys := maManual;
  pmUndo.AutoHotkeys := maManual;
  {$ENDIF}
end;

procedure TFrm_ysbZjpx_pxjh.OpenSpreadSheet;
begin
  if OpenDialog.Execute then
  begin
    NewSheet(OpenDialog.FileName);
    try
      try
        cxSpreadBook.LoadFromFile(OpenDialog.FileName);
      except
        ActiveMDIChild.Close;
        raise ESpreadSheetError.CreateFmt('Invalid data in file %s',
          [OpenDialog.FileName])
      end;
    finally
      actShowGrid.Checked := cxSpreadBook.ShowGrid;
    end;
  end;
end;
procedure TFrm_ysbZjpx_pxjh.NewSheet(const ASheetName: string = '');
begin
{  TFeatureChildForm.Create(Self);
  if ASheetName <> '' then
    ActiveMDIChild.Caption :=  ASheetName
  else
    ActiveMDIChild.Caption :=  'WorkBook - ' + IntToStr(Self.MDIChildCount);}
  with cxSpreadBook do
    OnSetSelection := cxSpreadBookSetSelection;
end;

procedure TFrm_ysbZjpx_pxjh.actOpenSpreadSheetExecute(Sender: TObject);
begin
OpenSpreadSheet;
end;

procedure TFrm_ysbZjpx_pxjh.FormCreate(Sender: TObject);
var
  yyyymm:string;
  aaa:TMemoryStream;
begin
  Dm_ysbZjpx_pxjh:=TDm_ysbZjpx_pxjh.Create(self);
  DateTimePicker1.Date:=now();
  yyyymm:=formatdatetime('yyyyMM',DateTimePicker1.date);
  dm_ysbzjpx_pxjh.cx(yyyymm);
  if dm_ysbzjpx_pxjh.dst_pxjh.IsEmpty then
  begin
   MessageBox(Handle, PChar('无数据!'), PChar('提示'), 64);
   exit;
  end;
  aaa:=TMemoryStream.Create;
  try
  dm_ysbzjpx_pxjh.dst_pxjhpxnr.SaveToStream(aaa);
  cxSpreadBook.LoadFromStream(aaa);
  finally
  aaa.Free;
  end;
end;

procedure TFrm_ysbZjpx_pxjh.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
Dm_ysbZjpx_pxjh.Free;
end;
procedure TFrm_ysbZjpx_pxjh.SaveSpreadSheet;
var
aaa:TMemoryStream;
begin
  aaa:=TMemoryStream.Create;
  try
    cxSpreadBook.SaveToStream(aaa);
    dm_ysbzjpx_pxjh.dst_pxjh.edit;
    dm_ysbzjpx_pxjh.dst_pxjhpxnr.LoadFromStream(aaa);
    dm_ysbzjpx_pxjh.dst_pxjh.Post;
  finally
    aaa.Free;
  end;
end;


procedure TFrm_ysbZjpx_pxjh.actPrintExecute(Sender: TObject);
begin
  dxComponentPrinter1.ReportLink[0].Print(True, nil);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -