Excel Buffer-Stream functions

Kratos3064Kratos3064 Posts: 14Member
edited 2019-08-08 in NAV Three Tier
Hi, I recently got to know you cannot use SelectSheetsName / OpenBook functions from ExcelBuffer record for AL extensions. Instead BC has provided SelectSheetsName and OpenBookStream.

In the older versions, I can enter the name of the file and the sheets in the parameters. This will generate an Excel file.

In AL, the datatype of the first parameter of the functions is an InStream function. Ive not worked on Instream / Outstream functions. Ive tried to google, but I don't get how it works. Can someone help me out in explaining it and also help me in showing an example for these functions.

Thanks in advance.

Best Answer


  • Kratos3064Kratos3064 Posts: 14Member
    ftornero wrote: »
    Hello @Kratos3064,

    Here you have an example to read an Excel File.
    codeunit 50104 LoadExcel
        trigger OnRun()
            UploadIntoStream('Load Excel File', '', 'Excel File (.xlsx)|*.xlsx', NombreFicheroLocal, FicheroInStream);
            Nombrehoja := ExcelBuf.SelectSheetsNameStream(FicheroInStream);
            ExcelBuf.OpenBookStream(FicheroInStream, Nombrehoja);
            if ExcelBuf.FindLast() then begin
                celdasleidas := ExcelBuf.Count;
                Message('Cells read %1', celdasleidas);
            ExcelBuf: Record "Excel Buffer";
            FicheroInStream: InStream;
            NombreHoja: Text;
            NombreFicheroLocal: Text;
            celdasleidas: Integer;

    Thank you @ftornero
Sign In or Register to comment.