导出到excel,将数字转换成三位逗号分隔的样式,清空浏览器客户端的缓存,生成缩略图

/// <summary>
/// 功能:导出到excel
/// </summary>
/// <param name="oDS"></param>
void ExportExcel(DataSet oDS)
{
Response.Clear();  
Response.Charset   =   "gb2312;";  
Response.ContentType   =   "application/vnd.ms-excel";  
System.IO.StringWriter   oSW   =   new   System.IO.StringWriter();  
HtmlTextWriter   oHW   =   new   HtmlTextWriter(oSW);  
DataGrid   oDG   =   new   DataGrid();  
oDG.DataSource   =   oDS.Tables[0];  
oDG.DataBind();  
oDG.RenderControl(oHW);  
Response.Write(oSW.ToString());  
Response.Flush();  
Response.Close();
}
----
function formatNum(s) //将数字转换成三位逗号分隔的样式
{
  if(!/^(/+|-)?/d+(/./d+)?$/.test(num)){alert("wrong!"); return num;}
  var re = new RegExp().compile("(//d)(//d{3})(,|//.|$)");
  num += ""; while(re.test(num))
    num = num.replace(re, "$1,$2$3")
  return num;
}
alert(formatNum(-12345678.123));
alert(formatNum("12345678.123"));
alert(formatNum("10000000000000000000000000000000000000000"));
---------
清空缓存
<META   HTTP-EQUIV="Pragma"   CONTENT="no-cache">    
  <META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache">    
  <META   HTTP-EQUIV="Expires"   CONTENT="0">    
-----------------
/// 
///  清空浏览器客户端的缓存
/// 
public  static  void  ClearClientPageCache()
{
HttpContext.Current.Response.Buffer=true;
HttpContext.Current.Response.Expires  =  0;
HttpContext.Current.Response.ExpiresAbsolute=DateTime.Now.AddDays(-1);
HttpContext.Current.Response.AddHeader("pragma","no-cache");
HttpContext.Current.Response.AddHeader("cache-control","private");
HttpContext.Current.Response.CacheControl="no-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(true);

--------------
生成缩略图
protected System.Web.UI.HtmlControls.HtmlInputFile File1;

private void Button1_Click(object sender, System.EventArgs e)
        {
            System.Drawing.Image tmp1 = System.Drawing.Image.FromStream(this.File1.PostedFile.InputStream);
            System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
            System.Drawing.Image tmp2 = tmp1.GetThumbnailImage(tmp1.Width/2,tmp1.Height/2,myCallback, IntPtr.Zero);

               
            string newPath = imgPath.Replace("image002","tmp1_" + DateTime.Now.Millisecond.ToString());
            tmp2.Save(newPath, System.Drawing.Imaging.ImageFormat.Jpeg);

            this.Image2.ImageUrl = newPath;

            tmp1.Dispose();
            tmp2.Dispose();
        } 


 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值