Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

NAV2015 excel buffer problem

Posted on by 366

Hi all,

I have a problem to catch up with new version of excel buffer. I'm creating a simple codeunit to export to excel.

xb - Record: excel buffer

This is the code:

OnRun()
------------------------------
xb.DELETEALL(FALSE);
xb.ClearNewRow;
xb.NewRow;

xb.AddColumn ('text1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);

xb.CreateBook('s1');
xb.WriteSheet('2','','');
xb.DELETEALL(FALSE);

xb.GiveUserControl;
ERROR('');

but nothing appears. no result. no excel is showing. Can anyone tell me what's wrong?

Thank you for any inputs.

*This post is locked for comments

  • Verified answer
    joemarselo Profile Picture
    joemarselo 366 on at
    RE: NAV2015 excel buffer problem

    hi all, i think i have got the answer for this:

    joemarselo.wordpress.com/.../my-version-of-multiple-excel-sheets-using-excel-buffer

  • joemarselo Profile Picture
    joemarselo 366 on at
    RE: NAV2015 excel buffer problem

    thank you Vishal, thank you Suresh. both suggestions works well for 1 sheet.

    what to do to make multi sheets?

    my codes is:

    xb.DELETEALL(FALSE);
    
    xb.SetUseInfoSheet;
    xb.ClearNewRow;
    xb.NewRow;
    xb.AddInfoColumn ('info1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);
    
    xb.ClearNewRow;
    xb.NewRow;
    xb.AddColumn ('text1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);
    
    xb.CreateBook('s1');
    xb.WriteSheet('','','');
    xb.DELETEALL(FALSE);
    
    xb.ClearNewRow;
    xb.NewRow;
    xb.AddColumn ('text2',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);
    
    xb.WriteSheet('','','');
    xb.DELETEALL(FALSE);
    
    xb.CloseBook;
    xb.OpenExcel;
    
    xb.GiveUserControl;
    ERROR('');

    that code is wrong, giving error message. no excel is showing. Can anyone tell me what's wrong?

    Thank you for any inputs.


  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: NAV2015 excel buffer problem

    After adding the column in the excel buffer you don't need to use CreateBook ,WriteSheet functions and then delete. Use CreateBookAndOpenExcel funciton in the excel buffer or  Here is the code

    xb.DELETEALL(FALSE);

    xb.ClearNewRow;

    xb.NewRow;

    xb.AddColumn ('text1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);

    xb.CreateBook(FileName,SheetName);

    xb.WriteSheet(ReportHeader,CompanyName2,UserID2);

    xb.CloseBook;

    xbOpenExcel;

    xb.GiveUserControl

    ERROR('');

    OR

    xb.DELETEALL(FALSE);

    xb.ClearNewRow;

    xb.NewRow;

    xb.AddColumn ('text1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);

    xb.CreateBookAndOpenExcel(FileName,SheetName,ReportHeader,COMPANYNAME,USERID);

    ERROR('');

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: NAV2015 excel buffer problem

    Hi,

    Try this.

    This should work.

    xb.DELETEALL(FALSE);

    xb.NewRow;

    xb.AddColumn('text1',FALSE,'',FALSE,FALSE,FALSE,'',xb."Cell Type"::Text);

    xb.CreateBookAndOpenExcel('D:\S1.xlsx','Sheet1','','','');

    xb.DELETEALL(FALSE);

    ERROR('');

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans