I'm writing a record to Excel such as 1/6 but Excel shows this as a date. How can I change the Excel cell type by c#?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
If you have data that can be interpreted multiple ways (1/2, fraction or Jan 2, etc), you need to put an apostrophe (') before the data. That, or set the cell's format to Text.
When programming with Excel, the best thing to do is start recording a macro and perform the steps you would normally take to format the cells. Stop recording and go into Excel's VBA editor and see what happens. Often, the recorder puts a lot of extra commands in, but you can learn a thing or two by looking at the code.
What do you want to see? Try writing
'1/6
if you want a string, or =1/6 is you want the number.