Page 1 of 1

Migration from 4 to 5: repeat first n rows in print setup

Posted: Mon Feb 10, 2014 8:27 pm
by maz65
Hello Lars,
during migration I am facing a different behaviour from version 4 to 5.
The need is to set the first 5 rows to be repeated on every page, like a header.

In version 4 there was a coding like this:

Code: Select all

    // printer settings
    // This will remove the psoPortrait option and seems to default to Landscape.
    XLS[0].PrintSettings.Options := [];
    // for repeating print the first 5 rows, you must set an internal name
    with XLS.InternalNames.Add do
         begin
         BuiltInName := bnPrintTitles;
         Definition := 'Sheet1!$A$1:$IV$5';
         Name := FormatDateTime('YYYYMMDDHHNNSSZZZ',now); // always internal name, if not an excel 2007 error will raise
         end;
    // ... other settings ...
    XLS[0].PrintSettings.PaperSize := psA4;
    XLS[0].PrintSettings.Options := XLS[0].PrintSettings.Options + [psoGridlines];
    XLS[0].PrintSettings.FitWidth  := 1;
    XLS[0].PrintSettings.FitHeight := 0;
    XLS[0].WorkspaceOptions := XLS[0].WorkspaceOptions + [woFitToPage];
Now when recompiling there is an error on Internalnames and BuiltInName:
E2250 There is no overloaded version of 'Add' that can be called with these arguments
E2003 Undeclared identifier: 'BuiltInName'

Probably the things are changed: how to set the first 5 rows to be repeated on every page ?
I haven't find this information in Samples.
Thanks in advance, Regards
-Massimo

Re: Migration from 4 to 5: repeat first n rows in print setup

Posted: Thu Feb 13, 2014 9:01 am
by larsa
Hello

Use PrintTitles. Example:

Code: Select all

  //* Set columns (to the left) and rows (at the top)
  //* that are repeated on each page. To set only one of them, set
  //* the other to -1.
  XLS[0].PrintSettings.PrintTitles(-1,-1,0,4);

Re: Migration from 4 to 5: repeat first n rows in print setup

Posted: Thu Feb 13, 2014 11:27 am
by maz65
Hello Lars,
thanks, your suggestion is working, but.... in print preview, after page 14 and for all remaining 34 pages, the header is not duplicated. Only empty cells.

Re: Migration from 4 to 5: repeat first n rows in print setup

Posted: Fri Feb 14, 2014 9:19 am
by larsa
Hello

I could not reproduce this.