I need to send a formula to excel from a CU and return the result.
I can not do what I need, this is my code:
ExcelBuffer.NewRow;
ExcelBuffer.AddColumn(vFormula,TRUE,'',FALSE,FALSE,FALSE,'',ExcelBuffer."Cell Type"::Number);
***option 1:
ExcelBuffer.CreateBookAndOpenExcel('\\naviserver\RED\Libro1.xlsx','Hoja1','header',COMPANYNAME,USERID);
problem: passes the formula but does not close,therefore the code that follows is not executed
***option 2:
ExcelBuffer.CreateBook('\\naviserver\RED\Libro1.xlsx','Hoja1');
problem:does not pass the formula as CreateBookAndOpenExcel but if it can be closed,the code that follows does run but since it does not save the formula it reads ''
ExcelBuffer.CloseBook;
ExcelBuffer.OpenBook('\\RED\MyBook.xlsx','Sheet1');
ExcelBuffer.ReadSheet();
IF ExcelBuffer.FINDFIRST THEN
REPEAT
txtValor := txtValor + ExcelBuffer."Cell Value as Text" + '\';
UNTIL ExcelBuffer.NEXT = 0;
MESSAGE(txtValor);
Variable (temporary=Yes) ExcelBuffer record 370
functions:
txtValor (text,250)
I also tried functions in table 370, but the instance fails me
SabeBook, Internal, Global, Parameters: txtFileName(text,250)
XlWrkBk.SaveAs(txtFileName,'xlAddIn','','','','',1,'','','','','');
QuitApp, Internal, Global
XlApp.Quit;
I need guidance because I do not know what I'm doing wrong.
THANKS BY ADVANCE!!
0
Answers
Excel Buffer generates xml file and doesn't calculate formulas.
To calculate formulas you have to use Excel Interop.
Here is an example how to achieve this.
1. Function to generate file with formula and get formulas value 2. Add some code to Excel buffer:
Add these lines to UTgetGlobalValue function: Add this new function: