Page 1 of 2
User functions
Posted: Thu Sep 19, 2013 10:03 am
by odisej
Hi
As far as I can understand (I haven't checked this though) there was option in older xls to define user functions. I can see OnFunction event in new version but I can't find the place where this is executed or AddUserFunction which should be used to register user function. Is this still supprted in new version or not? If not, will you support this? We need this very much as we have a million custom functions.
Grega
Re: User functions
Posted: Thu Sep 19, 2013 12:09 pm
by larsa
Hello
You don't have to define user functions. Just enter them in the formula. The OnFunction event is however never fired. Will fix that in the next update.
Re: User functions
Posted: Mon Sep 23, 2013 6:55 am
by odisej
larsa wrote:Hello
You don't have to define user functions. Just enter them in the formula. The OnFunction event is however never fired. Will fix that in the next update.
Do you have any idea when next update will be ready? I can miss some things and move on but I can miss those functions.
Re: User functions
Posted: Mon Sep 23, 2013 2:30 pm
by larsa
Hello
It will not take long, as most a week.
Re: User functions
Posted: Mon Sep 30, 2013 9:35 am
by odisej
Anything new on the subject?
Thanks
Re: User functions
Posted: Mon Sep 30, 2013 2:14 pm
by larsa
Hello
The update is ready now.
Re: User functions
Posted: Tue Oct 01, 2013 8:00 am
by odisej
Hi Lars
On the registered users download page it says I can download 5.20.01. Is that just the wrong text? I need XE version.
Re: User functions
Posted: Thu Oct 10, 2013 11:21 am
by odisej
Is this working? I have Delphi XE and I have formula like =MyFormula(1) in the cell. When I click into the cell, I get exception. I also don't get any event for this assignment:
XSS.XLS.OnFunction := MyFunction;
When I call this and I debug, I step into this:
procedure TXLSReadWriteII5.SetFunctionEvent(const Value: TFunctionEvent);
begin
end;
It's empty?
Re: User functions
Posted: Fri Oct 11, 2013 7:54 am
by larsa
Hello
Use the OnUserFunction event. The OnFunction event is only there to avoid compiler errors (if it was removed). There will be a sample on how to use OnUserFunction in the next update.
Re: User functions
Posted: Mon Oct 14, 2013 6:36 am
by odisej
I've used now OnUserFunction event but I get access. I have =MYFUNC(1) in the cell.
Debug:
TXLSWorksheet.GetAsFormula at step Result := FOwner.Formulas.DecodeFormula(FCells,FIndex,Ptgs,Sz,False); I get access.
Going deeper I get into DecodeFmla, there is a big case and first loop gets to xptg_EXCEL_97, second loop to xptgNum and third loop to xptgFuncVar97 where crashes at S := ExcelFunctions[...
Re: User functions
Posted: Mon Oct 14, 2013 9:36 am
by larsa
Hello
There is a sample on how to use user functions in update 5.20.04
Re: User functions
Posted: Mon Oct 14, 2013 1:34 pm
by odisej
I changed the demo this way:
procedure TfrmMain.btnReadClick(Sender: TObject);
begin
XLS.Filename := edReadFilename.Text;
XLS.Read;
XLS[0].AsInteger[0,0] := 4;
XLS[0].AsInteger[0,1] := 5;
XLS[0].AsFormula[0,2] := 'SUM(A1:A2)';
XLS[0].AsFormula[0,3] := 'TEST_NUM_1ARG(8)';
end;
When I press Calculate button, I never drop into XLSUserFunction. perhaps I'm doing something wrong?
Grega
Re: User functions
Posted: Mon Oct 14, 2013 4:23 pm
by larsa
Re: User functions
Posted: Tue Oct 15, 2013 6:38 am
by odisej
I added but...
Looking at TXLSFormulaEvaluator.DoEvaluate, Sum function goes to xptg_EXCEL_97, FStack.Push, then to xptgFuncVar97 where DoFunction is called.
Same procedure for custom function goes to xptg_EXCEL_97, then to xptgInt97 where 8 is pushed to stack and finished.
Re: User functions
Posted: Fri Oct 18, 2013 10:34 am
by odisej
Could you please look at this issue. I can't move forward.
Thanks
Grega