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

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
maz65
Posts: 20
Joined: Sun Feb 09, 2014 6:52 pm

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

Post 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
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

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

Post 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);
Lars Arvidsson, Axolot Data
maz65
Posts: 20
Joined: Sun Feb 09, 2014 6:52 pm

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

Post 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.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

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

Post by larsa »

Hello

I could not reproduce this.
Lars Arvidsson, Axolot Data
Post Reply