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

📄 uxlssheet.pas

📁 TMS Component Pack Pro v4.2
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  FDrawing.InsertAndCopyRowsAndCols(FirstRow, LastRow, DestRow, aRowCount, FirstCol, LastCol, DestCol, aColCount, SheetInfo);
end;

procedure TWorkSheet.DeleteRowsAndCols(const aRow, aRowCount, aCol, aColCount: word; const SheetInfo: TSheetInfo);
var
  r: TXlsCellRange;
begin
  if (aRowCount>0) then
  begin
    FCells.DeleteRows(aRow, aRowCount, SheetInfo);
    FDrawing.DeleteRows(aRow, aRowCount, SheetInfo);
    FRanges.DeleteRowsOrCols(aRow, aRowCount, SheetInfo, false);
    FNotes.DeleteRows(aRow, aRowCount, SheetInfo);
    FHPageBreaks.DeleteRows(aRow, aRowCount);
    r.Left:=0;r.Right:=Max_Columns;r.Top:=aRow; r.Bottom:=aRow+aRowCount;
    FHLinks.DeleteRange(r, 1, 0, SheetInfo);
  end;
  if (aColCount>0) then
  begin
    FCells.DeleteCols(aCol, aColCount, SheetInfo);
    FDrawing.DeleteCols(aCol, aColCount, SheetInfo);
    FRanges.DeleteRowsOrCols(aCol, aColCount, SheetInfo, true);
    FNotes.DeleteCols(aCol, aColCount, SheetInfo);
    FVPageBreaks.DeleteCols(aCol, aColCount);
    r.Top:=0;r.Bottom:=Max_Rows;r.Left:=aCol; r.Right:=aCol+aColCount;
    FHLinks.DeleteRange(r, 0, 1, SheetInfo);
  end;

end;


procedure TWorkSheet.ArrangeInsertRowsAndCols(const InsRowPos, InsRowCount, InsColPos, InsColCount: integer; const SheetInfo: TSheetInfo);
begin
  //PENDING: Optimize this
  FCells.ArrangeInsertRowsAndCols(InsRowPos, InsRowCount, InsColPos, InsColCount, SheetInfo);
  FDrawing.ArrangeInsertRowsAndCols(InsRowPos, InsRowCount, InsColPos, InsColCount, SheetInfo);
end;



procedure TWorkSheet.AssignDrawing(const Index: integer; const Data: string;
  const DataType: TXlsImgTypes);
begin
  FDrawing.AssignDrawing( Index, Data, DataType);
end;

procedure TWorkSheet.GetDrawingFromStream(const Index: integer; const Data: TStream;
  var DataType: TXlsImgTypes);
begin
  FDrawing.GetDrawingFromStream( Index, Data, DataType);
end;

function TWorkSheet.DrawingCount: integer;
begin
  Result:= FDrawing.DrawingCount;
end;

function TWorkSheet.GetDrawingRow(index: integer): integer;
begin
  Result:= FDrawing.DrawingRow[index];
end;

function TWorkSheet.GetDrawingName(index: integer): widestring;
begin
  Result:= FDrawing.DrawingName[index];
end;

procedure TWorkSheet.DeleteHPageBreak(const aRow: word);
begin
  inherited;
  FHPageBreaks.DeleteBreak(aRow);
end;

procedure TWorkSheet.DeleteVPageBreak(const aCol: word);
begin
  inherited;
  FVPageBreaks.DeleteBreak(aCol);
end;

procedure TWorkSheet.InsertHPageBreak(const aRow: word);
begin
  inherited;
  FHPageBreaks.AddBreak(aRow);
end;

procedure TWorkSheet.InsertVPageBreak(const aCol: word);
begin
  inherited;
  FVPageBreaks.AddBreak(aCol);
end;

procedure TWorkSheet.ArrangeCopySheet(const SheetInfo: TSheetInfo);
begin
  inherited;
  FCells.ArrangeInsertSheet(SheetInfo);
  FDrawing.ArrangeCopySheet(SheetInfo);
end;

function TWorkSheet.GetColWidth(const aCol: Word): integer;
var
  index: integer;
begin
  if not FColumns.Find(aCol, Index) then Result:=DefColWidth else Result:=FColumns[Index].Width;
end;

function TWorkSheet.GetRowHeight(const aRow: integer): integer;
begin
  if not FCells.RowList.HasRow(aRow) then Result:=DefRowHeight else
  Result:= FCells.RowList.RowHeight(aRow);
end;

procedure TWorkSheet.SetColWidth(const aCol: Word; const Value: integer);
var
  Index: integer;
begin
  if FColumns.Find(aCol, Index) then
    FColumns[Index].Width:=Value
  else
    FColumns.Insert(Index, TColInfo.Create(aCol, Value, 15, 0));
end;

procedure TWorkSheet.SetRowHeight(const aRow, Value: integer);
begin
  FCells.RowList.SetRowHeight(aRow, Value);
end;

function TWorkSheet.GetColHidden(const aCol: Word): boolean;
var
  index: integer;
begin
  if not FColumns.Find(aCol, Index) then Result:=false else Result:=FColumns[Index].Options and $1 = $1;
end;

function TWorkSheet.GetRowHidden(const aRow: integer): boolean;
begin
  if not FCells.RowList.HasRow(aRow) then Result:=false else
  Result:= FCells.RowList[aRow].IsHidden;
end;

procedure TWorkSheet.SetColHidden(const aCol: Word; const Value: boolean);
var
  Index: integer;
begin
  if FColumns.Find(aCol, Index) then
  begin
    if Value then
    begin
      FColumns[Index].Options:=FColumns[Index].Options or $1;
    end else
    begin
      if FColumns[Index].Width=0 then FColumns[Index].Width:=$A;
      FColumns[Index].Options:=FColumns[Index].Options and not $1;
    end;
  end
  else
    if Value then
      FColumns.Insert(Index, TColInfo.Create(aCol, $A, 15, $1));
end;

procedure TWorkSheet.SetRowHidden(const aRow: integer;const Value: boolean);
begin
  FCells.RowList.AddRow(aRow);
  FCells.RowList[aRow].Hide(Value);
end;


function TWorkSheet.GetColFormat(const aCol: integer): integer;
var
  index: integer;
begin
  if not FColumns.Find(aCol, Index) then Result:=-1 else Result:=FColumns[Index].XF;
end;

function TWorkSheet.GetRowFormat(const aRow: integer): integer;
begin
  if not FCells.RowList.HasRow(aRow) or not FCells.RowList[aRow].IsFormatted then Result:=-1 else
  Result:= FCells.RowList[aRow].XF;
end;

procedure TWorkSheet.SetColFormat(const aCol: integer; const Value: integer);
var
  Index: integer;
  i: integer;
begin
  if FColumns.Find(aCol, Index) then
    FColumns[Index].XF:=Value
  else
    FColumns.Insert(Index, TColInfo.Create(aCol, DefColWidth, Value, 0));

  //Reset all cells in column to format XF
  for i:=0 to FCells.CellList.Count-1 do
    if FCells.CellList[i].Find(aCol, Index) then FCells.CellList[i][Index].XF:=Value;
end;

procedure TWorkSheet.SetRowFormat(const aRow, Value: integer);
var
  i: integer;
begin
  FCells.RowList.AddRow(aRow);
  FCells.RowList[aRow].XF:= Value;

  //Reset all cells in row to format XF
  if(aRow>=0) and (aRow<FCells.CellList.Count) then
    for i:=0 to FCells.CellList[aRow].Count-1 do FCells.CellList[aRow][i].XF:=Value;

end;

function TWorkSheet.GetAnchor(const Index: integer): TClientAnchor;
begin
  Result:= FDrawing.GetAnchor(Index);
end;

procedure TWorkSheet.SetAnchor(const Index: integer; const aAnchor: TClientAnchor);
begin
  FDrawing.SetAnchor(Index, aAnchor);
end;


function TWorkSheet.CellMergedBounds(const aRow, aCol: integer): TXlsCellRange;
var
  i: integer;
begin
  //Find the cell into the MergedCells array
  Result.Left:=aCol;
  Result.Right:=aCol;
  Result.Top:=aRow;
  Result.Bottom:=aRow;
  for i:=0 to FRanges.Count-1 do
    if FRanges[i] is TMergedCells then
      if (FRanges[i] as TMergedCells).CheckCell(aRow, aCol, Result) then exit;
end;

function TWorkSheet.CellMergedList(const index: integer): TXlsCellRange;
var
  i, p, k: integer;
begin
  //Find the cell into the MergedCells array
  Result.Left:=0;
  Result.Right:=0;
  Result.Top:=0;
  Result.Bottom:=0;
  if index<0 then exit;
  p:=0;
  for i:=0 to FRanges.Count-1 do
    if FRanges[i] is TMergedCells then
    begin
      k:=(FRanges[i] as TMergedCells).MergedCount;
      if index<p+k then
      begin
        Result:=(FRanges[i] as TMergedCells).MergedCell(index-p);
        exit;
      end;
      inc (p, k);
    end;
end;

function TWorkSheet.CellMergedListCount: integer;
var
  i: integer;
begin
  Result:=0;
  for i:=0 to FRanges.Count-1 do
    if FRanges[i] is TMergedCells then
      inc(Result, (FRanges[i] as TMergedCells).MergedCount);
end;

procedure TWorkSheet.UnMergeCells(aRow1, aCol1, aRow2, aCol2: integer);
var
  x: integer;
  i: integer;
begin
  if aRow1>aRow2 then begin x:=aRow2;aRow2:=aRow1; aRow1:=x;end;
  if aCol1>aCol2 then begin x:=aCol2;aCol2:=aCol1; aCol1:=x;end;

  for i:=0 to FRanges.Count-1 do
    if FRanges[i] is TMergedCells then
    begin
      (FRanges[i] as TMergedCells).UnMergeCells(aRow1, aCol1, aRow2, aCol2);
    end;
end;

procedure TWorkSheet.MergeCells(aRow1, aCol1, aRow2, aCol2: integer);
var
  x: integer;
  Mc: TMergedCells;
  i: integer;
  bRow1, bCol1, bRow2, bCol2: integer;
begin
  if aRow1>aRow2 then begin x:=aRow2;aRow2:=aRow1; aRow1:=x;end;
  if aCol1>aCol2 then begin x:=aCol2;aCol2:=aCol1; aCol1:=x;end;

  //We have to take all existing included merged cells

  Mc:=nil;
  repeat
    bRow1:=aRow1; bRow2:=aRow2; bCol1:=aCol1; bCol2:=aCol2;
    for i:=0 to FRanges.Count-1 do
      if FRanges[i] is TMergedCells then
      begin
        Mc:=(FRanges[i] as TMergedCells);
        Mc.PreMerge(aRow1, aCol1, aRow2, aCol2)
      end;
  until (aRow1=bRow1) and (aRow2=bRow2) and (aCol1=bCol1) and (aCol2=bCol2);

  if Mc=nil then Mc:=FRanges[FRanges.Add(TMergedCells.Create)] as TMergedCells;
  Mc.MergeCells(aRow1, aCol1, aRow2, aCol2);
end;


function TWorkSheet.TotalRangeSize(const SheetIndex: integer; const CellRange: TXlsCellRange): int64;
begin
  Result:= inherited TotalRangeSize(SheetIndex, CellRange)+
    FMiscRecords1.TotalSize +
    FHPageBreaks.TotalRangeSize(CellRange) +
    FVPageBreaks.TotalRangeSize(CellRange) +
    FCells.TotalRangeSize(CellRange)+
    FRanges.TotalRangeSize(CellRange) +
    FDrawing.TotalSize +
    FMiscRecords2.TotalSize+
    FNotes.TotalRangeSize(CellRange)+
    FColumns.TotalRangeSize(CellRange)+
    FHLinks.TotalRangeSize(CellRange);
end;

function TWorkSheet.TotalSize: int64;
begin
  Result:= inherited TotalSize+
    FMiscRecords1.TotalSize +
    FHPageBreaks.TotalSize +
    FVPageBreaks.TotalSize +
    FCells.TotalSize +
    FRanges.TotalSize +
    FDrawing.TotalSize +
    FMiscRecords2.TotalSize+
    FNotes.TotalSize+
    FColumns.TotalSize+
    FHLinks.TotalSize;
end;

procedure TWorkSheet.SetPageHeaderFooter(const P: TPageHeaderFooterRecord;
  const s: Widestring);
var
  OldSize: integer;
begin
  if P=nil then exit;
  OldSize:=P.DataSize;
  P.Text:=s;
  FMiscRecords1.AdaptSize(P.DataSize-OldSize);
end;

function TWorkSheet.HasHPageBreak(const Row: integer): boolean;
begin
  Result:=FHPageBreaks.HasPageBreak(Row);
end;

function TWorkSheet.HasVPageBreak(const Col: integer): boolean;
begin
  Result:=FVPageBreaks.HasPageBreak(Col);
end;


function TWorkSheet.GetPrintNumberOfHorizontalPages: word;
begin
  if FSetup= nil then Result:=1 else
    Result:= FSetup.FitWidth;
end;

function TWorkSheet.GetPrintNumberOfVerticalPages: word;
begin
  if FSetup= nil then Result:=1 else
    Result:= FSetup.FitHeight;
end;

function TWorkSheet.GetPrintScale: integer;
begin
  if FSetup= nil then Result:=100 else
    Result:= FSetup.Scale;
end;

function TWorkSheet.GetPrintToFit: boolean;
begin
  if FWsBool= nil then Result:=false else
    Result:= FWsBool.FitToPage;
end;

⌨️ 快捷键说明

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