How to export to Excel buffer in NAV2018

Hi Team,

I am new to export to excel buffer, I created a Table 1 contain these fields: No. (Code, 10), Type of Receipt (Option: Receipt,Contribution,Others), Posting Date (Date), Description (Text,30), Table 2 which is the G/L Entry fields: G/L Account No. (Code, 20), Debit Amount, Credit Amount.

I want the output No., Account Code, Description, Posting Date, Debit Amount, Credit Amount.

I wrote this code on the page action of Generate Receipt Journal But how can I filter with Type of Receipt or Posting Date when the generate Receipt Journal is clicked

ExcelBuf.DELETEALL;
WITH Header DO BEGIN
//
  BEGIN
  ExcelBuf.NewRow;
  ExcelBuf.AddColumn('No.,FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn(' Account Code',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('Description',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('Posting Date,FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('Base Amount',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('Transaction Amount',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('Currency',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('D_C',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  END;
  //Receipt
  Lines.RESET;
  Lines.SETRANGE("No.","No.");
  //Lines.SETRANGE(Type,Lines.Type::Receipt);
  IF Lines.FINDSET THEN BEGIN REPEAT
  //Debit
  ExcelBuf.NewRow;
  ExcelBuf.AddColumn("Bank Account",FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn(Lines."Posting Date",FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn(FORMAT(DATE2DMY(Lines."Posting Date",3))+'/'+FORMAT(DATE2DMY(Lines."Positing Date",2),3,0),FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn("No.",FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn("No.",FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  IF Bank.GET("Bank Account") THEN
  ExcelBuf.AddColumn(Bank.Name,FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn(Lines.Debit,FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn(Lines.Debit,FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('NGN',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);
  ExcelBuf.AddColumn('D',FALSE,'',TRUE,FALSE,FALSE,'',ExcelBuf."Cell Type"::Text);

Thanks

Just do a filter on the fields like on a normal report/codeunit etc.

THANKS