NAV 4.0, Localized Excel and property Formula

Martina_JindrůMartina_Jindrů Member Posts: 3
edited 2007-08-10 in NAV Tips & Tricks
Because in NAV is a small bug which don't allow write to property Formula of Cell US expression then it's big problem write transparent international application with localized Excel.

I found a small trick how to get subfolders for any folder though NAV don't know FOR EACH - Windows Script Host Object Model Folders and Files.

There is result:
variables:
Name DataType Subtype Length
loScript Automation 'Microsoft Script Control 1.0'.ScriptControl
lcCode Text 1024
loData Automation 'Microsoft Scripting Runtime'.Dictionary
lcPom Text 1024
lii Integer

CREATE(loData);
CREATE(loScript);
lcCode :='loCell.Formula=loList.Item(1);';
lii:=1;

// for each cell
XlCell:=XlWrkSht.Range(xlColID + xlRowID);

loScript.Language := 'JScript';
// Add objects
loScript.AddObject('loCell', XlCell); // excel cell
loScript.AddObject('loList', loData); // dictionary object

lcPom:=GetFormula(); // Formula definition
loData.Add(lii,lcPom); // Add formula to dictionary object
loScript.ExecuteStatement(lcCode); // Execute javascript 
loData.RemoveAll(); // remove item from dictionary 
loScript.Reset(); // reset Script object for next using

MartinaJ

Comments

  • kirankumarkirankumar Member Posts: 29
    Nice meeting you.

    I have tried with the example you provided. But I did't able to compile the code because of 'GetFormula()' Function it is not defined from where this function has to be called.

    Please, Provide the Solution for this.

    Regards,
    kiran.
    Hi
  • I'm sorry. GetFormula is trigger from table 370 (Excel Buffer)
    CREATE(loData); 
    CREATE(loScript); 
    lcCode :='loCell.Formula=loList.Item(1);'; 
    lii:=1; 
    
    // for each cell 
    XlCell:=XlWrkSht.Range('C5'); 
    
    loScript.Language := 'JScript'; 
    // Add objects 
    loScript.AddObject('loCell', XlCell); // excel cell 
    loScript.AddObject('loList', loData); // dictionary object 
    
    
    loData.Add(lii,'=SUM(C1:C4)'); // Add formula to dictionary object 
    loScript.ExecuteStatement(lcCode); // Execute javascript 
    loData.RemoveAll(); // remove item from dictionary 
    loScript.Reset(); // reset Script object for next using
    
Sign In or Register to comment.