FlexCel Studio for VCL/LCL
ContentsIndex
PreviousUpNext
TFlexCelImport.SetNamedRange Method

Modifies or adds a Named Range. If the named range exists, it will be modified, else it will be added. If the range is not user defined (like "Print_Range") it will have a one-char name, and the value is one of the constants: InternalNameRange_... Look at the example for more information.

Pascal
procedure SetNamedRange(var NamedRange: TXlsNamedRange);
C++
__fastcall SetNamedRange(TXlsNamedRange NamedRange);
Parameters 
Description 
var NamedRange: TXlsNamedRange 
Data of the named range.  

This will create a range for repeating the first 2 columns and rows on each printed page (on sheet 1):

var
  NamedRange: TXlsNamedRange;
begin
  FlexCelImport1.NewFile;

  InitializeNamedRange(NamedRange);  //To clear it.
  NamedRange.Name:=InternalNameRange_Print_Titles;
  NamedRange.RangeFormula:='=A1:IV2,A1:B65536';
  NamedRange.OptionFlags:=0;
  NamedRange.NameSheetIndex:=1;
  FlexCelImport1.SetNamedRange(NamedRange);
  deletefile('test.xls');
  FlexCelImport1.Save('test.xls');
end;

Note that in this example in particular (Print_Titles), the range has to have full rows/columns, as this is what Excel expects. You can not also use "A:B" notation, you need to use the full "A1:B65535" name.

Copyright (c) 2002-2008 TMS Software. All rights reserved.
What do you think about this topic? Send feedback!