/// <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();
}