Excel file using write range workbook

@Jyothi31,

This happens when your Datatable have null value in some column.

Get the data fixed using this code first and then use Write Range .

(From r In dtData.AsEnumerable
let ra = r.ItemArray.Select(Function (x) If(isNothing(x) OrElse String.IsNullOrEmpty(x.ToString.Trim), DBNull.Value, x)).toArray
Select dtCorrected.Rows.Add(ra)).CopyToDataTable()

Taken from this thread.