I need to set the first 14 characters in a cell to font yellow and the remaining characters to font black. The following code is how it would be done using an Excel marco/ole.
Anyone know how to do it in XLSReadWrite?
With ActiveCell.Characters(Start:=1, Length:=14).Font
.Name = "Century Gothic"
.FontStyle = "Regular"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.Color = -16711681
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
ActiveCell.Characters(Start:=1, Length:=14).Font
-
- Posts: 2
- Joined: Sat Jan 12, 2019 3:29 am
Re: ActiveCell.Characters(Start:=1, Length:=14).Font
Hello
You can use Simple tags for this. Example:
You can use Simple tags for this. Example:
Code: Select all
//* AsSimpleTags let you easily create formatted text with html-like tags.
//* There are no end tags. A tag sets an option, and that option is used
//* until a new tags replaces it. In order to write the "<", character,
//* write an empty tag "<>" in the text. Example: 'Two <> one'
//* The following tags can be uses:
//* <b> Turn bold on.
//* </b> Turn bold off.
//* <i> Turn italic on.
//* </i> Turn italic off.
//* <u> Turn underline on.
//* </u> Turn underline off.
//* <f:Font name> Changes the font name.
//* <s:nn> Changes the font size. Setting the size to zero sets the font size to the default size.
//* <c:xxxxxx> Changes the font color. The value xxxxxx is the hexadecimal RGB color value.
//* If xxxxxx is set to 'Auto', the default color will be used.
var
S : string;
begin
SW := TStopWatch.Create;
SW.Start;
S := XLS[0].AsString[1,1];
S := '<c:FFFF00><f:Courier New>' + Copy(S,1,14) + '<c:000000><f:Arial>' + Copy(S,15,MAXINT);
XLS[0].AsSimpleTags[1,1] := S;
Lars Arvidsson, Axolot Data
-
- Posts: 2
- Joined: Sat Jan 12, 2019 3:29 am
Re: ActiveCell.Characters(Start:=1, Length:=14).Font
Thank you Larsa. Worked well.