I have a simple template with 2 pivot tables.
The 1st one shows percentual values with default format with 2 decimal places.
The second one has only one decimal place changed by options in pivot table properties.
(Both tables update automatically with opening worksheet.)
Template:

After write some value to the template, calculate and save the result has bad format at the second pivot table.
The first pivot table with defalut format of values is still ok.

Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
const
cOrigFile = 'template.xlsx';
cTestFile = 'result.xlsx';
var
ASheet: TXLSWorksheet;
begin
CopyFile(cOrigFile,cTestFile,False);
xlsRW.Filename:= cTestFile;
xlsRW.Read;
ASheet:= xlsRW.SheetByName('Pivot');
asheet.asinteger[2,0]:=1; // cell C1
xlsRW.calculate;
xlsRW.Write;
end;
end.
Josef Kohout