Trying to load the Almacen.xlsx into Excel2016 I get an xml error in the "sharedstrings.xml" file at offset 563101 ("invalid xml character"). The string around this offset is 'TABLERO ASADO TABLEREO TD-SR1 '#$85#$85'TD-SR5'. Looks like an ANSI codepage-to-UTF8 conversion problem because Dbf is ANSI and the interla Excel xml files are expected to be UTF-8.
Is the Dbf-File in your previous post exactly the same file from which this faulty xlsx file was generated? Or can you find out the encoding of the dbf? Looking at your Dbf-File in the previous post by means of MyDbfStudio I see that the file is encoded with codepage 1252 (not sure though whether MyDbfStudio extracts the encodings correcttly...). When you now read the strings from dbf you must convert them to utf8 before writing them to fpspreadsheet.
The following code fragment (based on your test project) shows you what I mean. It is untested, though, there may still be some typos here and there:
uses
LConvEncoding;
const
DBF_ENCODING = 'cp1252'; // adapt if your "real" file is encoded differently
function DBFTableToWorksheet(tableName: string; h: TsWorksheet): boolean;
var
...
tmp, nomCampo: RawByteString; // they were type "string", but declaring them as RawByteString prevents FPC from doing its own conversions
encoded: Boolean; // new variable needed
begin
...
for c:=0 to Dbf2.FieldCount-1 do begin
nomCampo := Dbf2.FieldDefs[c].Name;
h.WriteText(0, c, ConvertEncodingToUTF8(nomCampo, DBF_ENCODING, encoded));
// the call to ConvertEncodingToUTF8 converts the field names to UTF8. Can be skipped if all field names are ASCII (all chars < #128)
h.WriteHorAlignment(0, c, haCenter);
end;
...
for c:=0 to Dbf2.FieldCount-1 do begin
tmp := Dbf2.Fields[c].AsString;
h.WriteText(f, c, ConvertEncodingToUTF8(tmp, DBF_ENCODING, encoded)); // dto with the field values, but do not skip this!
end;
...
Give this a try, even if you don't know the correct dbf encoding. Above code makes sure that no invalid UTF8 characters are in the file. And maybe Excel is able to read this file correctly.