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 someone help me on this to only write date, month and year not time stamp @Palaniyappan@Lahiru.Fernando or anyone. Thanks
i think it is because of excel format whenever we insert the value through write cell or whatever method it automatically turn into that format.
if you are using just template excel to store the values we can change the format to the excel as one time activity so that it will not create any time stamp. thanks.
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”
wb1.Save
wb1.Close
excel.Quit
ws1 = Nothing
wb1 = Nothing
excel = Nothing
GC.Collect
And also please review the below new activity called Format cells. thanks.
I am sorry and forgot to mention that, i am working on csv file. if i use workbook it may lead to double steps. could you please provide me any alternative steps?