Excel - Format column to text before writing

@mohammedamaan,

I don’t think we have activities to do that, but if you have few rows of data and (I hope you are trying to write a number into fields and they are converting to some other formats ), you can directly paste the values by appending “'” , I mean (') a single quote before the data so that it will write as it is.

If you have huge data, or anyway you want to change the format and you want to write the values, here is a piece of code which will help you in changing the formats

   Dim excel As Microsoft.Office.Interop.Excel.Application
    Dim wb As Microsoft.Office.Interop.Excel.Workbook
    Dim ws As Microsoft.Office.Interop.Excel.Worksheet
    excel = New Microsoft.Office.Interop.Excel.Application
    wb = excel.Workbooks.Open(PathOfFile, [ReadOnly]:=False) 
    excel.Visible = True
    ws = CType(wb.Sheets(Sheet Name), Microsoft.Office.Interop.Excel.Worksheet)
    ws.Activate()
    ws.Range("F:F").NumberFormat = "@"
    wb.Save()
    wb.Close()
    excel.Quit()
1 Like