0

I am working on MVC4 format. I have a column which has HH:MM format.When i export to excel everything works fine. i mean in excel it is still HH:MM format But when value of hours is greater than 24 then its showing as HH:MM:SS

eg : 04:00 is showing as 04:00 but 31:42 is showing as 31:42:00.

can i use some style or something like that which will affect only that column not any other

How can i fix this problem ?

I have gone through Format HTML table cell so that Excel formats as text? and http://cosicimiento.blogspot.in/2008/11/styling-excel-cells-with-mso-number.html

but how can i format hh:mm to [hh]:mm so that if hours are greater than 24 it still remain in [hh]:mm format

Community
  • 1
  • 1
Mahajan344
  • 2,492
  • 6
  • 39
  • 90

2 Answers2

0

Just write the given code below. Its working fine.

HttpContext.Current.Response.Write("<style> TD { mso-number-format:\'@'; } </style>");
Robert
  • 5,278
  • 43
  • 65
  • 115
0

Manas answer it's almost correct, just the backslash is in wrong position. Correct line code is:

HttpContext.Current.Response.Write("<style> TD { mso-number-format:'\@'; }