[fpc-pascal] Explicit encoding of LF in XML

Ludo Brands ludo.brands at free.fr
Fri Aug 12 16:31:38 CEST 2011


> All,
> 
> Looking at multiline support of text/string cells for export 
> to Excel XML format.
> 
> My code, such as:
>     TDOMElement(FieldNode).SetAttribute('ss:Type', 'String');
>     FNode := 
> Foutputdoc.CreateTextNode(LeftStr(UTF8Decode(EF.Field.AsString
> ), 32767)); writes out a cell like:
> 
> <Cell><Data ss:Type="String">First line.
> Second line</Data></Cell>
> (Separated by CR LF - changing it to only LF with a hex 
> editor doesn't help)
> 
> Excel needs an encoded LF:
> <Cell><Data ss:Type="String">First line.
Second line</Data></Cell>
> 
> How can I produce that?
> 

Uses strutils;
...
Foutputdoc.CreateTextNode(LeftStr(UTF8Decode(AnsiReplaceStr(AnsiReplaceStr(E
F.Field.AsString,#10,'
'),#13,'')),32767));

Ludo




More information about the fpc-pascal mailing list