WorkerBeeJ
Programmer
I'm writing rows out to excel using an interop, and I'm having trouble figuring out how to specify how excel should write certain cells. The many of the numbers have leading zeros, which are being left off because the number type is set to "general" and not "text". Does anyone know how I can set this property so that my leading zeros are left in?
Here's a snippet of my code:
Dim oExcel As New Excel.Application()
oExcel.Visible = False
Dim oWorkbook As Excel.Workbook
oWorkbook = oExcel.Workbooks.Add
Dim oWorksheet As Excel.Worksheet
Dim oRange As Excel.Range
oRange = DirectCast(oWorkSheet.Cells(iRow, 1), Excel.Range)
'(doesn't work: oWorkSheet.Cells(iRow, 1).Type = "Text"
oRange.Value = sBusinessUnit
Thanks!
BTW, using leading ticks would technically work, but my users can't have them in there.
Here's a snippet of my code:
Dim oExcel As New Excel.Application()
oExcel.Visible = False
Dim oWorkbook As Excel.Workbook
oWorkbook = oExcel.Workbooks.Add
Dim oWorksheet As Excel.Worksheet
Dim oRange As Excel.Range
oRange = DirectCast(oWorkSheet.Cells(iRow, 1), Excel.Range)
'(doesn't work: oWorkSheet.Cells(iRow, 1).Type = "Text"
oRange.Value = sBusinessUnit
Thanks!
BTW, using leading ticks would technically work, but my users can't have them in there.