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

📄 basecell.pas

📁 相关的销售服务管理行业的一个软件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  if not Cell1.DoLogin( '吉大工易软件', 176, '84FDFCFEB8007104A8FDDB04B708' ) then
    MessageDlg( '注册码有误', mtWarning, [mbOK, mbCancel], 0 );
  Cell1.AllowSizeCell:=False;
  Cell1.DoSetCellString(-1,-1,' ');
  SetUserFunction(Cell1);
  aPrintRow:=20;
  aPrintCol:=10;
  aStartRow:=3;
  aStartCol:=3;
  STARTROW:=7;
  STARTCOL:=2

{  Reg := nil;
  try
    begin
      Reg := TRegistry.Create;
      Reg.RootKey := HKEY_LOCAL_MACHINE;
      if Reg.OpenKey( 'SoftWare\GoEasySoftWare\Report', False ) then
      begin
        try
          aPrintCol := Reg.readInteger( 'PrintCol' );
          aPrintRow := Reg.readInteger( 'PrintRow' );
          aStartCol := Reg.readInteger( 'StartCol' );
          aStartRow := Reg.readInteger( 'StartRow' );
        except
        end;
      end;
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;}

end;

procedure TBaseCellForm.FormShow(Sender: TObject);
begin
  Cell1.DoSetBackGround(4);
//  Cell1.DoOpenFile('D:\test.cll');
end;

procedure aPrintf(Cell:TCell;PrintFlag:Boolean;showDia:Boolean);
begin
   if not PrintFlag then
     Cell.DoPrintPreview(True)
   else
     Cell.DoPrint(showDia);
end;
procedure TBaseCellForm.PrintCell(PrintFlag:Boolean;showDia:Boolean);
var i,j,m,n,int:Integer;
    SCol,SRow,ECol,ERow:Integer;
begin
  try
    Cell1.DoAppendPage('打印',1);
    Cell1.DoCopyPage(1,0);
    Cell1.DoSetCurrentPage(1);
    for i := 0 to Cell1.Cols - 1 do
        for j := 0 to Cell1.Rows - 1 do
        begin
           if Cell1.IsFormulaCell(i,j) then
              Cell1.DoDelFormula(i,j);
           if Cell1.IsReadOnlyCell(i,j) then
              Cell1.DoSetCellReadOnly(i,j,false);
        end;
    j:= Cell1.Cols mod aStartCol + aPrintCol;
    if j<>0 then  j:= Cell1.Cols div (aStartCol+aPrintCol)+1
    else j:= Cell1.Cols div (aStartCol+aPrintCol);
    n:= Cell1.Rows mod aStartRow + aPrintRow;

    if n<>0 then  n:= Cell1.Rows div (aStartRow+aPrintRow)+1
    else n:= Cell1.Rows div (aStartRow+aPrintRow);

    Cell1.DoAppendPage('打印',1);
    Cell1.DoCopyPage(2,1);
    Cell1.DoSetCurrentPage(2);

    Cell1.Cols:=aStartCol+aPrintCol;
    Cell1.Rows:=aStartRow+aPrintRow;
    SCol:=0;
    SRow:=0;
    ECol:=aStartCol+aPrintCol-1;
    ERow:=aStartRow+aPrintRow-1;
    //j:横向打印几页
    //M:纵向打印几页
    for m:=1 to n do
    begin
      for i:=1 to j do
      begin
        //画头
//        Cell1.DoAppendPage(inttostr(Cell1.Dogettotalpages),1);
        for int := astartcol - 1 to aStartCol+aPrintCol - 1 do
        Cell1.DoSetCurrentPage(1);
        Cell1.DoCopyArea(0,0,aStartCol,aStartRow);
        Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
        Cell1.DoPaste(0,0,true);

        //画横向
        Cell1.DoSetCurrentPage(1);
        Cell1.DoCopyArea(SCol,0,ECol,aStartRow);
        Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
        if i=1 then
          Cell1.DoPaste(0,0,true)
        else
          Cell1.DoPaste(aStartCol,0,true);

        //画纵向
        Cell1.DoSetCurrentPage(1);
        Cell1.DoCopyArea(0,SRow,aStartCol-1,ERow);
        Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
        if m=1 then
          Cell1.DoPaste(0,0,true)
        else
          Cell1.DoPaste(0,aStartRow+1,true);

        //画数据
        Cell1.DoSetCurrentPage(1);
        if (m=1) and(i=1) then
        begin
          Cell1.DoCopyArea(SCol+aStartCol,SRow+aStartRow,ECol,ERow);
          Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
          Cell1.DoPaste(aStartCol,aStartRow,true);
        end
        else if (m=1) then
        begin
          Cell1.DoCopyArea(SCol,SRow+aStartRow,ECol,ERow);
          Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
          Cell1.DoPaste(aStartCol,aStartRow,true);
        end
        else if (i=1) then
        begin
          Cell1.DoCopyArea(SCol+aStartCol,SRow,ECol,ERow);
          Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
          Cell1.DoPaste(aStartCol,aStartRow+1,true);
        end
        else
        begin
          Cell1.DoCopyArea(SCol,SRow,ECol,ERow);
          Cell1.DoSetCurrentPage(Cell1.DoGetTotalPages - 1);
          Cell1.DoPaste(aStartCol,aStartRow+1,true);
        end;

        aPrintf(Cell1,PrintFlag,ShowDia);
        Cell1.DoCutArea(aStartCol,0,Cell1.Cols,Cell1.Rows);

        SCol:=ECol+1;
        ECol:=ECol+aPrintCol-1;
      end;
        SRow:=ERow+1;
        ERow:=ERow+aPrintRow-1;
        SCol:=0;
        ECol:=aStartCol+aPrintCol-1;
    end;
  finally
    Cell1.DoSetCurrentPage(0);
    Cell1.DoDeletePage(1,2);
  end;
end;

procedure TBaseCellForm.ToolbarButton976Click(Sender: TObject);
//var
//  Reg: TRegistry;
begin
//  Reg:=nil;
  with TDefPrintColRowForm.Create(Self)do
  begin
    SpinEdit1.Value:=aPrintCol;
    SpinEdit2.Value:=aPrintRow;
    SpinEdit3.Value:=aStartCol;
    SpinEdit4.Value:=aStartRow;
    if ShowModal =mrOK then
    begin
      aPrintCol:=SpinEdit1.Value;
      aPrintRow:=SpinEdit2.Value;
      aStartCol:=SpinEdit3.Value;
      aStartRow:=SpinEdit4.Value;
//      Cell1.DoSaveFile(PubPath+FileName);
//      Cell1.SetUserString
         { try
            Reg := TRegistry.Create;
            Reg.LazyWrite := false;
            Reg.RootKey := HKEY_LOCAL_MACHINE;
            if Reg.OpenKey ( 'SoftWare\GoEasySoftWare\Report\', True ) then
            begin
                Reg.WriteInteger('PrintCol',aPrintCol);
                Reg.WriteInteger('PrintRow',aPrintRow);
                Reg.WriteInteger('StartCol',aStartCol);
                Reg.WriteInteger('StartRow',aStartRow);
                Reg.CloseKey;
            end;
          finally
            Reg.Free;
          End;}
    end;
    Release;
  end;
end;

procedure TBaseCellForm.ToolbarButton974Click(Sender: TObject);
begin
  Cell1.DoSetUnScrollCol(0,Cell1.DoGetCurrentCol-1);
  Cell1.DoSetUnScrollRow(0,Cell1.DoGetCurrentRow-1);
end;

procedure TBaseCellForm.ToolbarButton972Click(Sender: TObject);
begin
  PrintCell(True,True);
end;

procedure TBaseCellForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
  
end;

procedure TBaseCellForm.ToolbarButton973Click(Sender: TObject);
begin
  PrintCell(True,False);
end;

procedure TBaseCellForm.ClearCell;
var i,j:Integer;
    v:OleVariant;
begin
   for i:=STARTCOL to Cell1.Cols do
      for j:=STARTROW to Cell1.Rows do
      begin
         Cell1.DoGetCellData(i,j,v);
         if (varType(v)= varEmpty ) or (varType(v)= varNull) then Continue;
         Cell1.DoSetCellString(i,j,' ');
      end;
end;
function TBaseCellForm.IfCellEx(Cell:TCell;Index:Integer):Boolean;
begin
   Result:=False;
   if Index>= Cell.rows then
   begin
     Cell.Rows:=Index+5;
     Result:=True;
   end;
end;
procedure TBaseCellForm.SetCellRow0(Cell:TCell;Index:Integer);
var i:Integer;
begin
   for i:=Index to Cell.Rows do
     Cell.DoSetRowHeight(i,0);
   for i:=STARTROW to Index-1 do
     Cell.DoSetRowHeight(i,26);
end;
procedure TBaseCellForm.SetCellCol0(Cell:TCell;Index:Integer);
var i:Integer;
begin
   for i:=STARTCOL to Index-1 do
     Cell.DoSetColWidth(i,30);
   for i:=Index to Cell.Cols do
     Cell.DoSetColWidth(i,0);
end;
function TBaseCellForm.GetCellCol(Cell:TCell;NO:String;ID:Integer):Integer;
var aData:OleVariant;
    s:String;
    i:Integer;
begin
   Result:=-1;
   for i:=ID to Cell.Rows do
   begin
      Cell.DoGetCellData(0,i,aData);
      S:=aData;
      if trim(S)=trim(NO) then
      begin
        Result:=i;
        break;
      end;
   end;
end;
function TBaseCellForm.GetCellRow(Cell:TCell;NO:String):Integer;
var aData:OleVariant;
    s:String;
    i:Integer;
begin
   Result:=-1;
   for i:=STARTCOL to Cell.Cols do
   begin
      Cell.DoGetCellData(i,STARTROW-1,aData);
      S:=aData;
      if trim(S)=trim(NO) then
      begin
        Result:=i;
        break;
      end;
   end;
end;
function TBaseCellForm.GetCellCols(Cell:TCell):Integer;
var
    i,nW,Cols:Integer;
begin
   Cols:=0;
   for i:=0 to Cell.Cols-1 do
   begin
     Cell.DoGetColWidth(i,nW);
     if nW>0 then
       Cols:=Cols+1;
   end;
   Result:=Cols;
end;
procedure TBaseCellForm.Cell1ExecuteUserFunc(Sender: TObject;
  const name: WideString; rettype, paranum: Smallint;
  var paratype: Integer; var funcResult: OleVariant);
//var AData: OleVariant;
//DesignFlag: Boolean; //当前为设计状态
  procedure SetDay;
  var S: string;
    Para1: OleVariant;
  begin
    S := ShortDateFormat;
    TCell(Sender).DoFetchFuncParameter( 0, para1 );
    case Integer( para1 ) of
      0:
        begin
          funcResult := FormatDateTime('yyyy''年''mm''月''dd''日''',S_CurDate );
        end;
      1:
        begin
          funcResult := FormatDateTime('yyyy/mm/dd',S_CurDate );
        end;
      2:
        begin
          funcResult := FormatDateTime('mm/dd/yyyy',S_CurDate );
        end;
      - 1:
        begin
          funcResult := FormatDateTime('yyyy''年''mm''月''dd''日''',S_CurDate-1 );
        end;
      - 2:
        begin
          funcResult := FormatDateTime('yyyy/mm/dd',S_CurDate-1 );
        end;
      - 3:
        begin
          funcResult := FormatDateTime( 'mm/dd/yyyy',S_CurDate-1 );
        end;
    else
      begin
        funcResult := FormatDateTime('yyyy''年''mm''月''dd''日''',S_CurDate -1);
      end;
    end;
    ShortDateFormat := S;
  end;
  procedure SetMonth;
  var St: TSystemTime;
    Para1: OleVariant;
  begin
//    DateTimeToSystemTime( CurDate, ST );
    DateTimeToSystemTime( S_CurDate, ST );
    TCell(Sender).DoFetchFuncParameter( 0, para1 );
    case Integer( para1 ) of
      0:
        funcResult := IntToStr( ST.wYear ) + '年' + FormatStrFor0(IntToStr( ST.wMonth ),2) + '月';
      1:
        funcResult := IntToStr( ST.wYear ) + '/' + FormatStrFor0(IntToStr( ST.wMonth ),2);
      2:
        funcResult := FormatStrFor0(IntToStr( ST.wMonth ),2) + '/' + IntToStr( ST.wYear );
      - 1:
        begin
          if ST.wMonth = 1 then
          begin
            St.wyear := St.wyear - 1;
            st.wMonth := 12;
          end
          else
            st.wMonth := st.wMonth - 1;
          funcResult := IntToStr( ST.wYear ) + '年' + FormatStrFor0(IntToStr( ST.wMonth ),2) + '月';
        end;
      - 2:
        begin
          if ST.wMonth = 1 then
          begin
            St.wyear := St.wyear - 1;
            st.wMonth := 12;
          end
          else
            st.wMonth := st.wMonth - 1;
          funcResult := IntToStr( ST.wYear ) + '/' + FormatStrFor0(IntToStr( ST.wMonth ),2);
        end;
      - 3:
        begin
          if ST.wMonth = 1 then
          begin
            St.wyear := St.wyear - 1;
            st.wMonth := 12;
          end
          else
            st.wMonth := st.wMonth - 1;
          funcResult := FormatStrFor0(IntToStr( ST.wMonth ),2) + '/' + IntToStr( ST.wYear );
        end;
    else
      funcResult := IntToStr( ST.wYear ) + '年' + FormatStrFor0(IntToStr( ST.wMonth ),2) + '月';
    end;
  end;
  procedure SetYear;
  var St: TSystemTime;
    Para1: OleVariant;
  begin
    DateTimeToSystemTime( S_CurDate, ST );

⌨️ 快捷键说明

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