At this moment the only way to export the text of TAdvMemo with the formatting applied is by copying as HTML. You can do this with AdvMemo.CopyHTMLToClipboard;
I actually do this by exporting HTML to the stringstream. But the HTML output format is not simple enought, as can be accepted in "TRichString.FromHtml". I have to improve it "manually".
As Bruno said, FlexCel is not using mini HTML, but a "Excel compatible html" which is constrained to what Excel admits in a TRichString. So for example, "background-color" is ignored, since you can't change a part of the background of a cell.
Now, currently FlexCel parses <font "color"> and <font "face">, but not <font "style"> so most of the html above will be ignored. Some HTML that would work today with FlexCel could be:
<HTML>
<BODY bgColor=#050000 LINK=#0000FF VLINK=#0000FF ALINK=#0000FF>
[quote]
drop
table
if
exists
my_table
;
[/quote]
</BODY>
</HTML>
But I think it should be feasible to add font style support, so the original HTML will work without modifications. Once again, only what is possible to convert from HTML to internal Excel representation (TRichString). Excel doesn't support HTML directly, and mostly what you can change is limited to the font (size, name, color...)
An update: We've already modified the HTML engine so it can parse <font style=...> tags. Still as said before, only what Excel supports is imported: Basically font size, color, name and style (italics, bold). background-color can't sadly be imported as Excel doesn't support it.
TAdvMemo - Highlighter Font Style & Font Color export
I have found the best solution for my problem: RichText using TRTFLabel.
The principle of solution is here:
function 1 ..
var
ms : TMemoryStream;
begin
..
ms := TMemoryStream.Create;
try
AdvMemo1.SaveToRTFStream( ms, False );
ms.Position := 0;
rtflabel1.RTF.Lines.LoadFromStream( ms );
..
result := true;
finally
FreeAndNil( ms );
end;
end;
function 2 ..
begin
..FontStyle := rtflabel1.RTF.SelAttributes.Style;
..FontColor := rtflabel1.RTF.SelAttributes.Color;
..
rtflabel1.RTF.clear
end;
Then I work with classic SelStart, selLength and SelAttributes