ExcelBuffer

SynphonySynphony Member Posts: 7
I am fairly new to NAV (as a heads up). The two quick questions I have are related to the same project.

Using the ExcelBuffer is there a process to deal with reading a protected Excel file? Something along the lines of "ExcelBufferCover.ReadSheet(password);"

Using the ExcelBuffer what is the easiest way to make NAV's decisions case insensitive, for example "IF.... = 'Yes'" would also include 'yes', 'YES', and so on.

I appreciate any and all information.
2009 R2

Comments

  • David_CoxDavid_Cox Member Posts: 509
    As you are fairly new it is worth looking inside existing Dynamics NAV code for examples, I hope this will point you in the right direction.

    To answer Question 2 have a look at Report: 81 "Import Budget From Excel".
    There is a function 'AnalyzeData' where you will see the code you want to compare strings case insensitive by forcing it to Uppercase.
    UPPERCASE(ExcelBuf."Cell Value as Text")
    
        CASE TRUE OF
          (STRPOS(UPPERCASE(ExcelBuf."Cell Value as Text"),Text009) <> 0):
            BEGIN
              IF HeaderRowNo = 0 THEN BEGIN
                HeaderRowNo := ExcelBuf."Row No.";
                TempExcelBuf := ExcelBuf;
                TempExcelBuf.Comment := Text010;
                TempExcelBuf.INSERT;
              END ELSE
                ERROR(Text011);
            END; 
    

    Text009 = 'G/L ACCOUNT NO'
    Text010 = 'G/L Account No.'
    The code is looking for a header column that includes the text 'G/L ACCOUNT NO', so "G/L ACCOUNT NO","g/l account no." or "G/L Account No." will return TRUE and Text010 will become the Heading for that Column G/L Account No.

    HTH

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • SynphonySynphony Member Posts: 7
    Thanks for the response.

    Come to find out after altering the code to use the uppercase() function the field in excel is a Boolean field (which caused me compile errors and lead to investigation). As of now this is a non-issue, however toying around more with the uppercase() function I will definitely have uses for it in the future.
Sign In or Register to comment.