Since we've upgraded from XLS2 to XLS4, a lot of code syntax was "broken" by the upgrade because of so many changes. I'm very surprised no backwards compatibility!
Anyways, with XLS2, you can create a new font, assign it an index and then output your string using that newly created font as such:
with ReportSheet.Formats.Add do begin
ReportSheet.Fonts[FontIndex].Name := 'Arial';
ReportSheet.Fonts[FontIndex].Style := [xfsBold];
// Save Format index
FI := Index;
end;
// Use correct format index
ReportSheet.Sheets[0].WriteString(0,AdminRow,FI,'Full Match');
This doesn't work at all in XLS4 when you want to do the output WriteString. I can't figure for the life of me to get this to work in XLS4.
How to apply a created font format to a cell?
Re: How to apply a created font format to a cell?
Hello
Example: XLS.Sheets[0].Cell[0,0].AssignFont(MyTFont);
Example: XLS.Sheets[0].Cell[0,0].AssignFont(MyTFont);
Lars Arvidsson, Axolot Data
Re: How to apply a created font format to a cell?
Thanks Lars!
Again, in keeping with my XLS2 version program code, I would always create the XLS.Font.Add first and then XLS.Formats.Add and create an integer value to keep track of which Formats used which Font, like so:
with XLS.Formats.Add do
begin
FontIndex := 6;
HorizAlignment := chaCenter;
end;
And then FontIndex 6 ties back to a XLS.Font.Add that say was Arial and bold.
With your example in your reply above for the Fonts works great, but now I'm trying to figure out the Formats and how to tie them back to use the newly created Fonts.
Thanks again!
Again, in keeping with my XLS2 version program code, I would always create the XLS.Font.Add first and then XLS.Formats.Add and create an integer value to keep track of which Formats used which Font, like so:
with XLS.Formats.Add do
begin
FontIndex := 6;
HorizAlignment := chaCenter;
end;
And then FontIndex 6 ties back to a XLS.Font.Add that say was Arial and bold.
With your example in your reply above for the Fonts works great, but now I'm trying to figure out the Formats and how to tie them back to use the newly created Fonts.
Thanks again!
Re: How to apply a created font format to a cell?
Hello
Don't use FontIndex (or FormatIndex) properties. These are only for internal use, as they might change due to optimization when formats/fonts are added or deleted.
Don't use FontIndex (or FormatIndex) properties. These are only for internal use, as they might change due to optimization when formats/fonts are added or deleted.
Lars Arvidsson, Axolot Data