CmdFormat and DefaultFormats question

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
marten
Posts: 4
Joined: Mon Oct 24, 2016 8:43 am

CmdFormat and DefaultFormats question

Post by marten »

Is it possible to store a set CmdFormat for later use?

I know that I could use Defaults and DefaultFormat, but our code formats the whole sheet in one procedure and later fills it with data, so I cannot set one format enter some data and then set another.

How could I solve our problem? Would it be possible to save the parameters in TFont (or some other structure) and load them into CmdFormat when needed or can the data be loaded from XLS.CmdFormat.Defaults into CmdFormat to be applied with .Apply?

If I use CmdFormat without loading the info from one place then the maintenance of the code becomes really bad as changing the font from 11 to 12 for example would require 10 or more changes in code.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: CmdFormat and DefaultFormats question

Post by larsa »

Hello

I don't understand. Why do you want to save the properties in CmdFormat? Why can't you just execute your formatting procedure when you need it?

If you still feel you need to save the properties for later use, google for "Delphi serialization".
Lars Arvidsson, Axolot Data
marten
Posts: 4
Joined: Mon Oct 24, 2016 8:43 am

Re: CmdFormat and DefaultFormats question

Post by marten »

I think you misunderstood me.

In previous version I could create 2 different TFonts and then apply them in a procedure that formats the spreadsheet. Lets say the header to Arial 18 and Body to Arial 10 and Summary to Arial 18 again - I can use the predefined fonts for it. When I need to change the 10 to 11 for example, its just 1 place (font creation) to change it. I can do the formatting before any data is inserted into the table.

Now when I want to do the same thing I can use CmdFormat, but every time I have to define the font name and size. When I need to do the same - change the size from 10 to 11 - then I would need to change it in many places.

My question was is there a easy way to store the font name, size etc. in some structure and load them into CmdFormat when needed ? (similar to how Defaults work, but I can't use defaults as they cannot be used to set different formatting before any data is inserted).
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: CmdFormat and DefaultFormats question

Post by larsa »

Hello

I will add an Assign method to CmdFormat.Font where you can assign a TFont, like: XLS.CmdFormat.Font.Assign(Font);

Will include this in the next update.
Lars Arvidsson, Axolot Data
Post Reply