GridView export to excel 格式参考

 

mso-number-format:"0\.000" 3 Decimals 
mso-number-format:"\#\,\#\#0\.000" Comma with 3 dec 
mso-number-format:"mm\/dd\/yy" Date7 
mso-number-format:"mmmm\ d\,\ yyyy" Date9 
mso-number-format:"m\/d\/yy\ h\:mm\ AM\/PM" D -T AMPM 
mso-number-format:"Short Date" 01/03/1998 
mso-number-format:"Medium Date" 01-mar-98 
mso-number-format:"d\-mmm\-yyyy" 01-mar-1998 
mso-number-format:"Short Time" 5:16 
mso-number-format:"Medium Time" 5:16 am 
mso-number-format:"Long Time" 5:16:21:00 
mso-number-format:"Percent" Percent - two decimals 
mso-number-format:"0%" Percent - no decimals 
mso-number-format:"0\.E+00" Scientific Notation 
mso-number-format:"\@" Text 
mso-number-format:"\#\ ???\/???" Fractions - up to 3 digits (312/943) 
mso-number-format:"\0022£\0022\#\,\#\#0\.00" £12.76 
mso-number-format:"\#\,\#\#0\.00_ \;\[Red\]\-\#\,\#\#0\.00\ " 2 decimals, negative numbers in red and signed
(1.56   -1.56)
 

 

在导出时,设定格式

 sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            
string s = e.Row.Cells[2].Text;
            
if (s == "0.16")
            {
                e.Row.Cells[
2].BackColor = System.Drawing.Color.FromName("#99cc00");
                e.Row.Cells[
3].Attributes.Add("style"@"mso-number-format:'\@';text-align:right;");
            }
            
if (s == "0.2")
            {
                e.Row.Cells[
2].BackColor = System.Drawing.Color.FromName("#99ccff");
            }

        }

    }

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2021-12-12
  • 2022-12-23
  • 2022-02-18
  • 2022-01-05
  • 2021-05-03
  • 2021-05-30
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-08-30
  • 2021-12-02
  • 2021-05-31
相关资源
相似解决方案