Field-Map Scripting

4.6.4.21 KeepColsTogether

KeepColsTogether




Prototype:

procedure KeepColsTogether(const C1,C2 :integer; const Level_ :integer; const ReplaceBiggerLevels_ :boolean);

Description:

Tells the document that it must try to keep together the cols between col1 and col2 (inclusive) when printing. This method does nothing to the resulting Excel file since this is not an Excel feature. To actually do something, you need to call AutoPageBreaks after calling this method.

Syntax:

xls.KeepColsTogether(1,c,1,false);


Part

Description


C1

Variable declared as integer. It represents the first col of the group you want to keep together.


C2

Variable declared as integer. It represents the last col of the group you want to keep together.


level

Variable declared as integer. Set this parameter to 0 to remove the condition to keep cols together. Any bigger than zero value will mean that the cols must be kept together. You can use more than one level to try to keep different groups together.

If all cols cannot be kept together in one page, it will try to keep as much cols with higher levels as possible.

Return value:

none


See also:

Landscape , SetPrintMargins , SetHeader , SetFooter , SetHeaderAndFooter , SetFirstHeaderAndFooter , SetTitleRows , SetTitleRowsAndCols , InsertHPageBreak , InsertVPageBreak , CreateHeaderOfTableContent , CreateTableOfContent , AddBackToTableOfContent , SetPrintArea , RowCount , ColCount , Header and footer codes , Predefined paper sizes, KeepColsTogether, KeepRowsTogether, AutoPageBreaks, PrintNumberOfHorizontalPages, PrintNumberOfVerticalPages, PrintToFit, Complex example


Example:

Var
  Row, Rows, Cols:integer;
  xls :TExcelWrapper;
Begin
  {document preparation}
  //...
  {managing worksheets}
  {setting cell values}

  xls.Landscape:=true;
  xls.SetPaperSize('A4');
  xls.SetPrintArea(1,1,Cols, Rows);
  xls.SetPrintMargins(25,25,20,25,10,10);
  xls.InsertHPageBreak(10,true);

  {making the sheet fit in one page of width }
  xls.PrintNumberOfHorizontalPages:=1; 
  xls.PrintToFit:=true;


  {document saving / previewing}
  //...
End.