Write todays date into a cell in excel file


#1

Hello everyone,

I am trying to write the date eg: “29” from “29/03/2018” into a cell in excel using
Date.Now.toString(“dd”) but I am getting an error.

An error has occured

Source: System.Xml

Message: Unable to cast object of type ‘Newtonsoft.Json.Linq.JValue’ to type ‘System.String’.

Exception Type: InvalidCastException

System.InvalidCastException: Unable to cast object of type ‘Newtonsoft.Json.Linq.JValue’ to type ‘System.String’.
at System.Xml.XmlException…ctor(SerializationInfo info, StreamingContext context)
at Void .ctor(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)(Object[] )
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at UiPath.Shared.JsonParser.DeserializeObject[T](String jsonValue)
at UiPath.Models.UiPathDuplexProxy.<>c__DisplayClass21_0.b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()


#2

Hi @jamnanin,
what activity did you used…
can you send the screen shot

Regards,
Arivu


#3

@arivu96 used the write cell activity


#4

@jamnanin,Use assign row(“headername”)=date inside the for each row of excel
Thanks,
Sreekanth.k


#5

I just want to write it in one of the cell and not all the rows


#6

@MAHESH1 @balupad14


#7

@jamnanin

From where you are accessing the date i.e “29” from “29/03/2018”

Regards,
Mahesh


#8

@jamnanin

Do this DateTime.Now.Day.Tostring

This will return the day of the DateTime.

Give this in Write Cell activity

Regards,
Mahesh


#9

@MAHESH1 Thanks man… It worked.