Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to add sales lines from an Excel file in NAV 2015

Posted on by 95
Hello, 
 
I had previously developed the process in Business Central and tried to replicate it in NAV 2015. However, I encountered an issue because in that version, the 'SelectSheetsNameStream' function does not exist in the 'Excel Buffer' table. How can I read and import Excel records and insert them as sales lines?
 
This is the code in Business Central for reading the Excel file:
    local procedure ReadExcelSheet()
    var
        FileMgt: Codeunit /File Management/;
        IStream: InStream;
        FromFile: Text[100];
    begin
        UploadIntoStream(UploadExcelMsg, '', '', FromFile, IStream);
        if FromFile <> '' then begin
            FileName := FileMgt.GetFileName(FromFile);
            SheetName := TempExcelBuffer.SelectSheetsNameStream(IStream);
        end else
            Error(NoFileFoundMsg);
        TempExcelBuffer.Reset();
        TempExcelBuffer.DeleteAll();
        TempExcelBuffer.OpenBookStream(IStream, SheetName);
        TempExcelBuffer.ReadSheet();
    end;
 
Thanks in advance.
  • isabtogumon Profile Picture
    isabtogumon 95 on at
    How to add sales lines from an Excel file in NAV 2015
    Thank you YUN ZHU for your response.
     
    I have adapted the import process, and it has worked correctly. However, I have some questions that were not addressed; I hope you can clarify them.
     
    The first one is: how can I filter the dialog box to display only Excel files? I used this line 'ServerFileName := FileMgt.UploadFile(Text001,'Excel file(.xlsx)|.xlsx'');' but I get an error.
     
    The second question is if it's possible to control up to which column number I want to read, for example, if I have 70 rows in a sheet but only want to read from row 1 to row 50.
     
    Thanks in advance.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    How to add sales lines from an Excel file in NAV 2015

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans