AsFormula =#N/A error

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
ASD
Posts: 2
Joined: Wed Oct 12, 2011 6:31 pm

AsFormula =#N/A error

Post by ASD »

Hello!
I try trial version of XLSReadWriteII 4.00.55a in Delphi XE2

Situation :

xls.sheets[0].AsFormula[1,1]:='A1+B1';

Result in excel = =#N/A

thx,
ASD
a_bloke
Posts: 3
Joined: Wed Oct 12, 2011 6:33 am
Location: Australia

Re: AsFormula =#N/A error

Post by a_bloke »

I have the same problem with the same trial version using D_2010 when trying:

xls.sheets[0].AsFormulaRef['H7'] := 'C7*D7';

Excel version 14.0.4734.1000 (32-bit)

....and still can't find a solution to the previous post about how to set currency formatting:

with XLRW.Sheet[0] do
begin
Range.ItemsRef['A2:J6'].FontStyle := [xfsBold];
Columns.AddIfNone(8,1); //Column 'I'
Columns[8].PixelWidth := 96;
Range.ItemsRef['A2:J6].VertAlignment := cvaCenter;
Range.ItemsRef['C5:I6].HorizAlignment := chaCenter;
AsFormula[8,5] := 'SUM(H6:H7)';
//
// This is where I would like to format Cell[8,5] as currency with 2 decimal places and a symbol, e.g. $87.23
end;
a_bloke
Posts: 3
Joined: Wed Oct 12, 2011 6:33 am
Location: Australia

Re: AsFormula =#N/A error

Post by a_bloke »

The only way I have found around the problem is the following....

xls.sheets[0].AsFormula[1,1]:='SUM(A1,B1)'; which could also be written as xls.sheets[0].AsFormula[1,1]:='SUM(A1:B1)'; in this case.

or in my case

xls.sheets[0].AsFormulaRef['H7'] := 'PRODUCT(C7:D7)';

But still haven't found a way to format cells as currency.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: AsFormula =#N/A error

Post by larsa »

Hello

The N/A error is fixed in the latest update.

When formatting numeric values, use the NumberFormat property. Example: XLS.Sheets[0].Cell[0,0].NumberFormat := '# ##0.000';
The format string is the same as in excel.
Lars Arvidsson, Axolot Data
ASD
Posts: 2
Joined: Wed Oct 12, 2011 6:31 pm

Re: AsFormula =#N/A error

Post by ASD »

[quote="larsa"]Hello

The N/A error is fixed in the latest update.

When formatting numeric values, use the NumberFormat property. Example: XLS.Sheets[0].Cell[0,0].NumberFormat := '# ##0.000';
The format string is the same as in excel.[/quote]

thanx, good job
Post Reply