Date is not valid

Hi all,

While exporting data from Report to excel sheet i got error as"Date is not valid"

in my Report there are Order date,Promised delivery date and Requested del date are the columns.

I have used below code in Sales Header- On Post dataItem()


xlBook := xlApp.Workbooks.Add;

xlSheet:= xlApp.ActiveSheet;

xlSheet.Name := ‘Booking’;



xlSheet.Range(‘A1’).Value:=“Sales Header”.FIELDCAPTION(“Order Date”);

xlSheet.Range(‘B1’).Value:=“Sales Header”.FIELDCAPTION(“Requested Delivery Date”);

xlSheet.Range(‘C1’).Value:=“Sales Header”.FIELDCAPTION(“Promised Delivery Date”);

IF"Sales Header".“Sell-to Customer No.”<> ‘’ THEN




xlSheet.Range(‘A’+FORMAT(RowId)).Value:=“Sales Header”.“Order Date.”;

xlSheet.Range(‘B’+FORMAT(RowId)).Value:=“Sales Header”.“Requested Delivery Date”;

xlSheet.Range(‘C’+FORMAT(RowId)).Value:=“Sales Header”.“Promised Delivery Date”;




xlApp.Visible := TRUE;


Is there any thing in need to add…

Thanks in Advance,.

It looks like one of the sales header record has blank Order Date or Requested Delivery Date or Promised Delivery Date.

You can add a condition like

IF “Promised Delivery Date” <> 0D THEN

xlSheet.Range(‘C’+FORMAT(RowId)).Value:=“Sales Header”.“Promised Delivery Date”;


Thanks for the reply…

Now I am able to get all column names in my excel sheet but i am not getting data into excel sheet(empty rows)

But When i preview my report and i am able to retrieve data with more than 100 records but in excel sheet it is showing empty rows with all column names

Y I am getting this problem???

Are you getting only last record?

You have written code in wrong place.

Write a code on OnAftergetrecord trigger .

No, i cannot see any data into my excel sheet…its showing empty rows throughout the sheet and its displaying only column names.
Now i had Replaced my code in Onaftergetrecord() and When i run report and preview, i am not able to see any generating of pages and even in excel sheet also.

But previously i can preview data in my report.