本文介绍了如何在c#中从数据网格格式化datagrid / excel列writtem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有以下代码绑定datagrid DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dt; dgGrid.DataBind(); 这个网格我写的是一个excel文件使用系统.io.file如下 String path = Application [UpldPath]。ToString()+ filename; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dt; dgGrid.DataBind(); //获取控件的HTML。 dgGrid.RenderControl(hw); //将HTML写回浏览器 string renderedGridView = tw.ToString(); File.WriteAllText(path,renderedGridView); 这是将excel写入特定路径。但是大量数字都带有科学记数法。 如何在写作时格式化excel专栏? Plz的建议。解决方案 I have the following code to bind datagridDataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dt;dgGrid.DataBind();this grid i'm writing to an excel file using system .io.file as below String path = Application["UpldPath"].ToString() + filename; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); DataGrid dgGrid = new DataGrid(); dgGrid.DataSource = dt; dgGrid.DataBind(); //Get the HTML for the control. dgGrid.RenderControl(hw);//Write the HTML back to the browser string renderedGridView = tw.ToString(); File.WriteAllText(path, renderedGridView);this is writing the excel to the specific path. But large numbers are coming with scientific notation.How to format the excel column while writing?Plz advice. 解决方案 这篇关于如何在c#中从数据网格格式化datagrid / excel列writtem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 19:53