Avatar of chkueh
chkueh
Flag for Singapore

asked on 

How to add " ' " when transferring DataGrid data to Excel?

Hi, Experts,
I would like to add " ' " in the excel cell to avoid zero missing for number format, for example (000123). I want whole number to be displayed in the  excel cell, without " ' " in excel the number will become (123) only.
Previously, i add Section A code to add " ' "  to get whole number displayed, but now is i cannot add " ' " for code in Section B.
Can any one tell me how to add " ' " before dr("No") ?

Thank you.
Best Regards,
--chkueh--
Section A:
Dim No As String = Trim(txtNo.Text)
excelWorksheet.Range("C4").Value = "'" & No 
 
Section B:
.Range("B" & i.ToString).Value = dr("No")
.Range("B" & i.ToString).HorizontalAlignment = Excel.Constants.xlLeft

Open in new window

Visual Basic.NETMicrosoft ExcelMicrosoft Development

Avatar of undefined
Last Comment
chkueh

8/22/2022 - Mon