I have an issue with taking a number string from SQL and putting it into excel, but excel formats the number without it's leading zeros.
Another program I wrote reads the excel and put it into a pdf. It is in this second program I decided to reappend the missing leading zeros.
I am using .PadLeft to do this and ran into some errors. For documentation sake, I am going to add this issue I found to SO and also answer it. Here was my problem:
I need the number string to be 10 digits, with zeros on the front up to 10 digits.
I have numbers like 77776666 coming from excel, they should be 0077776666 (10 digits) Here is what DIDN'T work. It did not append any zeros:
string insuranceID = Convert.ToString(xlRange.Cells[i, 21].Value2 ?? "");
insuranceID.PadLeft(10, '0');