How to create a Range Name at runtime?

I'm creating a spreadsheet template using FlexCel and the spreadsheet created will be used as a template for a FlexCel Report.

I'm having trouble defining the range names and would like to know if anyone has an example of how to use the TXLSNamedRange() function to define the areas of the report.

For example, how can I define that in the worksheet that I created lines 4 and 5 is a report band?

I need to create the worksheet entirely in Flexcel, that is, I can not use Excel to define the Range Names.

Thank you.

First just a note: If you are creating the file entirely in FlexCel, it might make sense to not use reports at all and just call SetCellValue to create the file. The reports are nice for designing the reports in Excel, but if you can't use Excel, reports aren't that useful.


Now, about the actual question, you are looking for:
http://www.tmssoftware.biz/flexcel/doc/net/api/FlexCel.Core/ExcelFile/SetNamedRange.html

But the simplest way to find out is to just run APIMate: Create a file in Excel, add a named range and save it. Go to the start menu, search for apimate and open it. Then open the file you created in Excel, and APIMate will tell you the code you need to add the same named range you added with Excel with FlexCel. You can use APIMate for most "How do I do feature x in FlexCel?" questions.

Edit: I posted the link to .NET docs, not VCL. Vcl doc is http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TExcelFile/SetNamedRange.html

Also I now noticed that we had spoken about this earlier today by mail, and the reason you need this is because Excel for iOS doesn't allow you to create names. In this case, indeed, you need to call SetNamedRange from FlexCel to do the same. You can see the actual code both with APIMate or in the code examples in the link above.

Adrian Gallero2018-08-31 23:30:18
Adrian,

O projeto que estou desenvolvendo gerará planilhas a partir de SELECTs criados pelo usuário.

O usuário poderá listar todos os dados obtidos e, nesse caso, eu crio a planilha usando o SetCellValue ou, então, o usuário poderá selecionar uma planilha de modelo criada no Excel e, nesse caso, eu utilizo o FlexCel Report.

Esse aplicativo rodará no Windows, macOS e iOS e, como o Excel para o iOS não possui o "Gerenciador de nomes" (Named Ranges), eu criei uma opção onde o usuário pode criar a planilha de modelo no iOS e definir os locais das bandas no meu aplicativo.

Com relação ao APIMAte, eu não lembrei desse utilitário (desculpe). Realmente ele é perfeito quando precisamos aprender como fazer algo no FlexCel.

Quanto ao help, eu já tinha lido esse tópico que vocÊ passou porém com dúvida sobre o que informar no parâmetro OptionFlag (também não encontrei essa informação no fonte do FlexCel). 

Como eu já disse uma vez para você, e volto a repetir, o FlexCel é excelente e a documentação eletrônica muito boa.

Agradeço sua atenção e já vi no APIMate como fazer o que preciso.

Obrigado.
Sorry, I put my last post in Portuguese. Here's what I wrote in English.

Adrian,

The project I'm developing will generate spreadsheets from user-created SELECTs.

The user can list all the data obtained, in which case I create the worksheet using SetCellValue or the user can select a template created in Excel, in which case I use the FlexCel Report.

This application will run on Windows, MacOS and iOS, and since Excel for iOS does not have "Named Ranges," I've created an option where the user can create the template worksheet in Excel for iOS and set the locations of bands in my app.

I did not remember APImate (sorry). It really is perfect when we need to learn how to do something on FlexCel.

I had already read the help topic you passed but I was not sure what to inform in the OptionFlag parameter (I also did not find this information in the FlexCel source).

As I once said to you, and I repeat, the FlexCel is excellent and the electronic documentation very good.

Thank you for your attention and I have already seen in APIMate how to do what I need.

Thank you