Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Clearing Excel Buffer

Posted on by Microsoft Employee

I Have this code, which creates multiple excel spreadsheets, however say the first one it creates is 10 line long, the next spreadsheet created will start at line 11. How can I prevent this?? 


recTiogaSetup.FINDFIRST;
recVendor.RESET;
recVendor.SETRANGE("Order Book EDI", recVendor."Order Book EDI"::Excel);
IF recVendor.FINDSET THEN REPEAT
blnFound1 := FALSE;
recExcelBufferTMP.DELETEALL;

// Create Titles
CLEAR(recPurchaseOrderTMP);
recExcelBufferTMP.NewRow;
recExcelBufferTMP.AddColumn('Vendor No.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recVendor."No.",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.NewRow;
recExcelBufferTMP.AddColumn('Vendor Name',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recVendor.Name,FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.NewRow;

// Crearte Headers
recExcelBufferTMP.NewRow;
recExcelBufferTMP.AddColumn('Document No.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Type.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('No.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Description',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Manufacturing Part No.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Quantity.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Outstanding Quantity.',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Direct Unit Cost',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Line Amount',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Order Date',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Requested Receipt Date',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn('Expected Receipt Date',FALSE,'',TRUE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);

recPurchaseOrder.RESET;
recPurchaseOrder.SETCURRENTKEY("Buy-from Vendor No.");
recPurchaseOrder.SETRANGE("Document Type", recPurchaseOrder."Document Type"::Order);
recPurchaseOrder.SETRANGE(Status, recPurchaseOrder.Status::Released);
recPurchaseOrder.SETFILTER("Expected Receipt Date",'<%1',WORKDATE);
recPurchaseOrder.SETRANGE("Buy-from Vendor No.", recVendor."No.");
IF recPurchaseOrder.FINDSET(FALSE,FALSE) THEN REPEAT

recPurchaseOrder."Last Chased" := CURRENTDATETIME;
recPurchaseOrder.MODIFY;

recPurchaseOrderLines.RESET;
recPurchaseOrderLines.SETRANGE("Document No.", recPurchaseOrder."No.");
recPurchaseOrderLines.SETRANGE(Type, recPurchaseOrderLines.Type::Item);
recPurchaseOrderLines.SETFILTER("Outstanding Quantity", '>%1', 0);
// Input Information
IF recPurchaseOrderLines.FINDSET(FALSE,FALSE) THEN REPEAT
blnFound1 := TRUE;
recPurchaseOrderLines.CALCFIELDS("Manufacturer Part No."); // TIO000016
recExcelBufferTMP.NewRow;
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Document No.",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines.Type,FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."No.",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines.Description,FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Manufacturer Part No.",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines.Quantity,FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Outstanding Quantity",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Direct Unit Cost",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Line Amount",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Order Date",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Requested Receipt Date",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
recExcelBufferTMP.AddColumn(recPurchaseOrderLines."Expected Receipt Date",FALSE,'',FALSE,FALSE,FALSE,'',recExcelBufferTMP."Cell Type"::Text);
UNTIL recPurchaseOrderLines.NEXT = 0;
recPurchaseOrderTMP := recPurchaseOrder;
UNTIL recPurchaseOrder.NEXT = 0;

VendorCreateExcel(recPurchaseOrderTMP, blnFound1, recExcelBufferTMP);
CLEAR(recPurchaseOrderTMP);
UNTIL recVendor.NEXT = 0;

*This post is locked for comments

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,135 Super User 2024 Season 2 on at
    RE: Clearing Excel Buffer

    Please share the solution which may help in future..

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Clearing Excel Buffer

    Resolved!

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