解决导出电子表格 当数字过多
2010-08-10 17:12
239 查看
导出按钮:
sgv1_RowDataBound:
daochu():
protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { if (sgv1.Rows.Count == 0) { Response.Write("<mce:script type="text/javascript"><!-- alert('数据库为空!') // --></mce:script>"); } else { ObjectDataSource1.SelectParameters.Clear(); ObjectDataSource1.SelectMethod = "get1"; ObjectDataSource1.TypeName = "excel"; ObjectDataSource1.DataBind(); sgv1.Columns.Clear(); sgv1.AutoGenerateColumns = true; sgv1.AllowPaging = false; sgv1.RowDataBound += new GridViewRowEventHandler(sgv1_RowDataBound); sgv1.DataBind(); daochu(); } }
sgv1_RowDataBound:
protected void sgv1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[15].Attributes.Add("class", "text"); e.Row.Cells[1].Attributes.Add("class", "text"); } }
daochu():
public void daochu() { string style = @"<style> .text { mso-number-format:/@; } </script> "; Response.ClearContent(); HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; Response.AddHeader("content-disposition", "attachment;filename=hyjjb.xls"); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); sgv1.RenderControl(htmlWrite); Response.Write(style); Response.Write(stringWrite.ToString()); Response.End(); }
相关文章推荐
- 在把table表格中的数据导出到Excel的时候,以科学计数法显示位数多的数字时怎么解决?(已解决)
- 从数据库中将SQL查询结果导出到Excel中中午乱码及数字问题解决
- php解决各种excel表格形式导出问题
- 导出Excel时,解决数字前的0问题
- JSP导出excle时类型字符串的数字不以科学计数法显示的解决方法
- 解决PHPExcel导出长数字末尾几位数为0的问题
- Html Table用JS导出excel格式问题 导出EXCEL后单元格里的000412341234会变成412341234 7-14 会变成 2018-7-14(7月14) 自定义格式 web利用table表格生成excel格式问题 js导出excel增加表头、mso-number-format定义数据格式 数字输出格式转换 mso-number-format:"\@"
- php导出电子表格
- 【java】opencsv导出csv之后的数字格式问题解决
- php导出CSV时,超长数字精度丢失问题与前导0的字符串丢失0的问题解决
- html table表格导出excel的方法 html5 table导出Excel HTML用JS导出Excel的五种方法 html中table导出Excel 前端开发 将table内容导出到excel HTML table导出到Excel中的解决办法 js实现table导出Excel,保留table样式
- GridView导出数据到excel数字变为科学记数法的问题的解决办法
- 解决HTML导出Excel表数字变成科学计数法
- [.Net] 导出Excel中身份证等数字串的解决方式
- 用POI导出excel时,较长的数字不想被自动变为科学计数法的解决方式
- 使用poi做excel导出时解决以文本格式存储的数字问题
- 导出csv文件数字会自动变科学计数法的解决方法
- JQuery Plugin-TableExport实现前端表格的导出功能(已解决表格pdf导出中文格式问题)
- GridView导出数据到excel数字变为科学记数法的问题的解决办法
- 解决AspNet中DataGrid GridView等列表控件导出Excel长数字显示成科学计数法的问题