用你的方法一就可以了,至于有0开头的字符,可以这样处理:比如gdv的第i列是有0开头的,给gdv加RowDataBound方法,protected void gdv_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[i].Attributes.Add("class", "text");
}这样处理后,0开头的数据导入EXCEL也不会丢失了记得抓紧给分~~~
{
e.Row.Cells[i].Attributes.Add("class", "text");
}这样处理后,0开头的数据导入EXCEL也不会丢失了记得抓紧给分~~~
protected void Button1_Click(object sender, EventArgs e)
{
ExportToExcel("application/ms-excel", "学生信息.xls"); }
public void ExportToExcel(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Output.Write(tw.ToString());
Response.Flush();
Response.End(); }
public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
}
3樓這個和我的方法一是一樣的呀,解決不了0開始的字串問題,看不出什麼不同,還是我沒看明白?
我希望是調用公司函數,然後在賦值時來判斷當前是否為數值型,單獨不加引號,可以嗎?
多謝各位的回復