File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -699,13 +699,14 @@ procedure TfrmExportGrid.btnOKClick(Sender: TObject);
699699
700700 // Prepare stream
701701 // Note that TStringStream + TEncoding.UTF8 do not write a BOM (which is nice),
702- // although it should do so according to TUTF8Encoding.GetPreamble.
702+ // although it has a property TUTF8Encoding.GetPreamble.
703703 // Now, only newer Excel versions need that BOM, so we add it explicitly here
704704 // P.S.: Note the boolean/False parameter for OwnsEncoding, so our global encodings are not destroyed after usage
705705 S := TStringStream.Create(' ' , Encoding, False);
706- if (CurrentExportFormat = efExcel) and (Encoding = TEncoding.UTF8) and radioOutputFile.Checked then begin
707- Bom := TBytes.Create($EF, $BB, $BF);
708- S.Write(Bom, 3 );
706+ if radioOutputFile.Checked then begin
707+ Bom := Encoding.GetPreamble;
708+ if Length(Bom) > 0 then
709+ S.WriteBuffer(Bom[0 ], Length(Bom));
709710 end ;
710711
711712 Header := ' ' ;
You can’t perform that action at this time.
0 commit comments