D2007: .Calculate does not flag xlsx file as "calculated"

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
maz65
Posts: 20
Joined: Sun Feb 09, 2014 6:52 pm

D2007: .Calculate does not flag xlsx file as "calculated"

Post by maz65 »

Hi Lars,
in versions older than 5.20.23 , there was this problem with a file with formulas:
1) perform the "XLSReadWriteII51.Calculate;" before writing
2) open the file with Excel
3) close the file without touching it : a message appears "do you want to save the changes made to file .... ?"
that means the formulas are calculated in that time and not when we force to calculate them in point 1).

Now in the latest versions, >= 5.20.53 and in the actual 5.20.77 , it is not working again.
Latest working version is 5.20.41

Let me know, thanks
Massimo

procedure TForm2.Button1Click(Sender: TObject);
begin
XLSReadWriteII51.Filename := 'c:\test1.xlsx';
XLSReadWriteII51[0].Columns.AddIfNone(0,20);
XLSReadWriteII51[0].Name := 'TEST1';
XLSReadWriteII51[0].AsInteger[1,1] := 1;
XLSReadWriteII51[0].AsInteger[1,2] := 3;
XLSReadWriteII51[0].AsFormula[1,3] := 'SUM(B2:B3)';
XLSReadWriteII51.Calculate;
// I also tried to force calculate of single cell but it is the same....
//XLSReadWriteII51[0].Calculate(1,3);
XLSReadWriteII51.Write;
end;
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: D2007: .Calculate does not flag xlsx file as "calculated"

Post by larsa »

Hello

Don't know why Excel asks: "do you want to save the changes made to file .... ?

This may happened on files created (and calculated) with Excel as well.
Lars Arvidsson, Axolot Data
maz65
Posts: 20
Joined: Sun Feb 09, 2014 6:52 pm

Re: D2007: .Calculate does not flag xlsx file as "calculated"

Post by maz65 »

Lars,
this should not be happen.

If I
- calculate the worksheet with XLSReadWrite
- save it, close the application
- reopen it with exel
- close excel
the file should close without asking anything from excel.

OR

If I
- calculate the worksheet with XLSReadWrite
- save it, close the application
- right click on the newly created file and select "print"
- after printing process, there is the asking from Excel/OS to save the file.
the file should be printed without asking anything from excel.

Until version 5.20.41 it worked in that way, and in the past you done some changes based on my support email request for the same reason.
And this happens only on files with formulas, so my suspect is something is not set correctly in excel file after calculation by XLSReadWriteII.

Regards,
Max
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: D2007: .Calculate does not flag xlsx file as "calculated"

Post by larsa »

Hello

I checked this a bit more:

The problem is that in order to tell excel that a workbook is calculated you must set the version of the calculation engine. The engine is a part of excel and not something XLSReadWriteII has access to. If the version number
is not correct, it may lead to errors when the sheets are calculated by excel. This was what happend when XLSReadWriteII assigned a fake value to the engine version.
Lars Arvidsson, Axolot Data
maz65
Posts: 20
Joined: Sun Feb 09, 2014 6:52 pm

Re: D2007: .Calculate does not flag xlsx file as "calculated"

Post by maz65 »

Hello
how is it possible to retrieve the calculation engine version from a file created with Excel 2007 and write the same value to the file created by XLSReadWriteII ?
thanks
Max
Post Reply