سؤال

I'm trying to export my data pro Excel using ASP. NET MVC 4, but the fields are not formatted like to know how do I format the date type fields

Below the line of my Append:

sb.Append("<td><font face=Arial size=" + "14px" + ">" + dr.dtLancamentoReceitaDespesaDataVencimento.ToString() + "</font></td>");
هل كانت مفيدة؟

المحلول

There's a good reference page here.

It obviously depends on the format you want. But as an example:

sb.Append(dr.dtLancamentoReceitaDespesaDataVencimento.ToString("MM/dd/yyyy"));

If you're in doubt as to the format to use I'd suggest trying the ISO 8601 format

.ToString("yyyy-MM-ddTHH\:mm\:ss.fffffffzzz");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top