I am trying to write today’s date into a cell in excel file using write cell activity. I am using System.Date.Now.ToString(“MM/dd/yyyy”) as value. While running/debugging I can see that i am getting only date without any timestamp where as when i am writing it on excel it is printing as below.
To be written in Excel
Expected : 12/16/2021
Actual : 12/16/2021 0:00 (0:00 referring as 12:00:00 AM)
Atlast i am writing this data into a csv file using Write CSV activity
Could you please try with the below simple vb code(invoke code activity) to convert the format of the column. Replace the A column with your column.
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb1 As Microsoft.Office.Interop.Excel.Workbook
Dim ws1 As Microsoft.Office.Interop.Excel.Worksheet
excel = New Microsoft.Office.Interop.Excel.ApplicationClass
wb1 = excel.Workbooks.Open(Your work book path)
ws1 = CType(wb1.Sheets(Your work sheet), Microsoft.Office.Interop.Excel.Worksheet)
ws1.Range(“A:A”).NumberFormat = “MM/dd/yyyy”
ws1 = Nothing
wb1 = Nothing
excel = Nothing
And also please review the below new activity called Format cells. thanks.