Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)
Suggested answer

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

(1) ShareShare
ReportReport
Posted on by 93
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.
Categories:
  • isabtogumon Profile Picture
    isabtogumon 93 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 63,013 Super User 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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,876 Super User

#2
Ludwig Reinhard Profile Picture

Ludwig Reinhard Microsoft Employee

#3
Martin Dráb Profile Picture

Martin Dráb 225,425 Super User

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans