Jimbo99999
asked on
VB.net - Outputting to Excel Formatting
Good Day Experts!
I have data that is defined in the SQL table as varchar that I am outputting to Excel. The data contains alpha code like RFDG as well as numerical code like 002. Since I need to keep the preceeding zeroes, I set the NumberFormat to the cell as "@". Now I get that little triangle in the corner of the cells that says "The Number in this cell is formatted as text..."
Is there anyway I can programatically get this to not show? The output is just for display purposes and there will be no totalling or manipulation by the Users.
Thanks,
jimbo99999
I have data that is defined in the SQL table as varchar that I am outputting to Excel. The data contains alpha code like RFDG as well as numerical code like 002. Since I need to keep the preceeding zeroes, I set the NumberFormat to the cell as "@". Now I get that little triangle in the corner of the cells that says "The Number in this cell is formatted as text..."
Is there anyway I can programatically get this to not show? The output is just for display purposes and there will be no totalling or manipulation by the Users.
Thanks,
jimbo99999
I believe in Excel, you can select "Format Cells" and change it from a number to text. If you want to do it from the VB side so that it goes in as text, then you can use a String.Format or String.PadfLeft/PadRight method.
ASKER
Hey There:
Here is what I have...how do I implement your response?
With oSheet.Range("A" + CStr(ExcelRow))
.Font.Size = 10
.Font.Name = "Segoe UI"
.Value = Code
.NumberFormat = "@"
.HorizontalAlignment = Excel.XlVAlign.xlVAlignCen ter
End With
Thanks,
jimbo99999
Here is what I have...how do I implement your response?
With oSheet.Range("A" + CStr(ExcelRow))
.Font.Size = 10
.Font.Name = "Segoe UI"
.Value = Code
.NumberFormat = "@"
.HorizontalAlignment = Excel.XlVAlign.xlVAlignCen
End With
Thanks,
jimbo99999
Is there a NumberAsText property? If so set that to False.
http://msdn.microsoft.com/en-us/library/office/aa224871(v=office.11)
http://msdn.microsoft.com/en-us/library/office/aa224871(v=office.11)
ASKER
I do not have that option.
What happens if you don't set the NumberFormat property at all? May if you don't set it to anything, Excel won't think of it as a number.
ASKER
I will not get the preceeding zeroes. for the "numerical" code data.
See if suggestion here works for you
http://stackoverflow.com/questions/9229644/how-to-remove-warnings-in-excel-generated-by-poi
http://stackoverflow.com/questions/9229644/how-to-remove-warnings-in-excel-generated-by-poi
Have you tried to change the order of assignment ??
like:
like:
.NumberFormat = "@"
.Value = Code
ASKER
Yes and I still receive same result.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good Day!
Using oXL.ErrorCheckingOptions.N umberAsTex t = False I have no more little green triangles.
At first I thought I was in trouble since the intellisense did not show .ErrorCheckingOptions for oXL.
jimbo99999
Using oXL.ErrorCheckingOptions.N
At first I thought I was in trouble since the intellisense did not show .ErrorCheckingOptions for oXL.
jimbo99999