How add new NamedRange?

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Warstone
Posts: 2
Joined: Tue Oct 26, 2010 12:36 pm

How add new NamedRange?

Post by Warstone »

Subj.

This code falls on assigning Name property:

XLSNamedRegion := XLS.InternalNames.Add;
XLSNamedRegion.BuiltInName := bnNone;
XLSNamedRegion.Name := 'MyCoolNamedRange';
XLSNamedRegion.Col1 := 0;
XLSNamedRegion.Col2 := 10;
XLSNamedRegion.Row1 := 0;
XLSNamedRegion.Row2 := 10;
cjmoore
Posts: 1
Joined: Mon Jan 14, 2013 10:23 am

Re: How add new NamedRange?

Post by cjmoore »

I'm trying this as well, did you get it to work?

NameArea1 := xls.InternalNames.Add;
NameArea1.BuiltInName := bnNone;
NameArea1.NameName := 'PerformanceDay';
NameArea1.Comment := 'Comment - Day Performance';
NameArea1.Definition := 'ProfitCentrePerf!$B$2:$AH$8';

The result in excel is an invalid area....

Name = 'erform'
Value=#N/A
Refers to= #N/A

Delphi XE with XLSReadWriteII 4.00.53
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: How add new NamedRange?

Post by larsa »

Hello

When you create a name you must specify the area in the Definition property. It's also importand that cells in the definition are absolute.

Code: Select all

var
  XLSNamedRegion: TInternalName;
begin
  XLSNamedRegion := XLSBook.XLS.InternalNames.Add;
  XLSNamedRegion.Name := 'MyCoolNamedRange';
  XLSNamedRegion.Definition := 'Sheet1!$A$2:$B$8';
Lars Arvidsson, Axolot Data
Post Reply