tags:

views:

919

answers:

3

i m writing a record to excel such as 1/6 but excel shows this as a date. how can i change excel cell type by c#

A: 

What do you want to see? Try writing '1/6 if you want a string, or =1/6 is you want the number.

Grzenio
i want to see what i write. i m reading records in a file. so sometimes string is came sometimes number is came. so generally i want to see what i write.i tried to change excel.coloms.numberformat....(like this) but nothing that i wanted is happened
A: 

want to see what i write. i m reading records in a file. so sometimes string is came sometimes number is came. so generally i want to see what i write. i tried to change excel.coloms.numberformat....(like this) but nothing that i wanted is happened

A: 

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.

Jason Z