When opening in Excel (2010 or 2016, in different machines) it triggers Protected View with message "Office has detected a problem with this file. Editing it may harm your computer. Click here for more details."
The problem is related to charts as if I remove the chart creation the file is OK (BFF validation PASSED).
I downloaded Microsoft BFFValidator (https://blogs.msdn.microsoft.com/opensp ... es-public/) to check the file. The validation status was FAILED. It refers to FontIndex element, but I have no idea what is wrong or how to fix it. The BFF report has links to the Microsoft documentation as well.
I have included a very simple example that generates the error. The included CreateCharts example has the same error. The component is XLSReadWriteII 5.0 (5.20.80).
Also included the output from BFFValidator.
If you need any more information, please let me know.
main.pas code:
Code: Select all
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XLSReadWriteII5, ExtCtrls, StdCtrls, ComCtrls, XLSSheetData5,
Xc12Utils5, BIFF_DrawingObjChart5, XPMan;
type
TfrmMain = class(TForm)
XLS: TXLSReadWriteII5;
procedure FormCreate(Sender: TObject);
private
FFontA: TFont;
FFontB: TFont;
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.FormCreate(Sender: TObject);
var
i: integer;
begin
XLS.Version := xvExcel97;
FFontA := TFont.Create;
FFontB := TFont.Create;
Randomize;
for i := 0 to 9 do begin
XLS[0].AsFloat[0,i] := Random(100);
XLS[0].AsFloat[1,i] := Random(100);
XLS[0].AsFloat[2,i] := Random(100);
XLS[0].AsFloat[3,i] := Random(100);
XLS[0].AsFloat[4,i] := Random(100);
end;
XLS.BIFF[0].Charts.Clear;
with XLS.BIFF[0].AddChart do begin
Col1 := 5;
Col2 := 11;
Series[0].Values := 'Sheet1!$A$1:$A$10';
// If font definition excluded, gives the same error.
// If font was defined via fontdialog (CreateCharts example), the error remained.
DefaultTextA.Font.Assign(FFontA);
DefaultTextB.Font.Assign(FFontB);
PlotArea.ChartType := xctLine;
PlotArea.HasLegend := true;
end;
XLS.Filename := 'C:\test0003.xls';
XLS.Write;
FFontA.Destroy;
FFontB.Destroy;
end;
end.
Code: Select all
<BFFValidation path="test0003.xls" datetime="10/24/16 12:44:53" result="FAILED">
<ParseStack>
<Type builtinType="Docfile" docName="MS-XLS" sectionTitle="Compound File" msdnLink="http://msdn.microsoft.com/en-us/library/b91df1c9-6bfa-4ab4-8218-7bb0d73624ca">
<Info>Built-in type "Docfile": The root storage object of an OLE compound file. For more information, see http://msdn.microsoft.com/en-us/library/dd942138.aspx.</Info>
</Type>
<Type builtinType="Stream" docName="MS-XLS" sectionTitle="Stream" msdnLink="http://msdn.microsoft.com/en-us/library/f67ac5ed-b0a7-4b2c-9b7a-28933eeaac7e" streamName="Workbook" streamOffset="0" hexStreamOffset="0x0">
<Info>Built-in type "Stream": Any stream object for OLE compound files. The entire file contents for other files.</Info>
</Type>
<Type docName="MS-XLS" sectionTitle="Workbook Stream (Workbook)" msdnLink="http://msdn.microsoft.com/en-us/library/f682f4b0-8c6b-444e-83f8-52d156f1e8ba" streamName="Workbook" streamOffset="1984" hexStreamOffset="0x7c0"/>
<Type docName="MS-XLS" sectionTitle="Workbook Stream (Workbook)" msdnLink="http://msdn.microsoft.com/en-us/library/f682f4b0-8c6b-444e-83f8-52d156f1e8ba" streamName="Workbook" streamOffset="1984" hexStreamOffset="0x7c0"/>
<Type docName="MS-XLS" sectionTitle="Substream" msdnLink="http://msdn.microsoft.com/en-us/library/dd947025(v=office.12).aspx" streamName="Workbook" streamOffset="2004" hexStreamOffset="0x7d4"/>
<Type docName="MS-XLS" sectionTitle="Record" msdnLink="http://msdn.microsoft.com/en-us/library/170e90ce-87d7-4758-9331-dcf14cd72388" streamName="Workbook" streamOffset="3168" hexStreamOffset="0xc60"/>
<Type docName="MS-XLS" sectionTitle="Fbi" sectionNumber="2.4.109" msdnLink="http://msdn.microsoft.com/en-us/library/F3D70B00-BE31-4223-B3EC-717DFAB54EC1" streamName="Workbook" streamOffset="3172" hexStreamOffset="0xc64"/>
<Type docName="MS-XLS" sectionTitle="FontIndex" sectionNumber="2.5.129" msdnLink="http://msdn.microsoft.com/en-us/library/B3413C2B-CA5B-4988-86BE-AB44BFE9E4D3" streamName="Workbook" streamOffset="3180" hexStreamOffset="0xc6c"/>
<Type builtinType="USHORT" streamName="Workbook" bitOffsetWithinStruct="0" hexBitOffsetWithinStruct="0x0" bitCount="16" streamOffsetOfStruct="3180" hexStreamOffsetOfStruct="0xc6c" streamOffset="3180" hexStreamOffset="0xc6c" childId="1" hexChildId="0x1">
<Info>Built-in type "USHORT": Unsigned 2-byte integer.</Info>
</Type>
</ParseStack>
<LastData><![CDATA[
07 00 -- -- -- -- -- -- -- -- -- -- -- -- -- -- ..
]]></LastData>
</BFFValidation>