我正在將數據表導出爲excel,並且一列在數據表中具有電話號碼,但在Excel中導出後,電話號碼coloumn將顯示爲指數。如何將指數格式化爲從導出到Excel的編號?
我需要數字,如何解決這個問題?
string fileName = "File" + DateTime.Now.ToString("MMddyyyy_HHmmss") + ".xls";
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
//Response.AddHeader("content-disposition", "attachment;filename=File.xls");
Response.ContentType = "application/vnd.ms-excel";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter);
DataGrid dataExportExcel = new DataGrid();
dataExportExcel.ItemDataBound += new DataGridItemEventHandler(dataExportExcel_ItemDataBound);
dataExportExcel.DataSource = dt;
dataExportExcel.DataBind();
dataExportExcel.RenderControl(htmlWrite);
System.Text.StringBuilder sbResponseString = new System.Text.StringBuilder();
sbResponseString.Append("<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:xlExcel8\" xmlns=\"http://www.w3.org/TR/REC-html40\"> <head></head> <body>");
sbResponseString.Append(stringWriter + "</body></html>");
Response.Write(sbResponseString.ToString());
Response.End();
與[this]相同(http://stackoverflow.com/questions/15024367/exporting-contacts-into-csv-file-automatically-format-mobile-numbers-into-scient#comment21113659_15024367)? – Sinatr 2013-03-19 11:00:16
你想以編程方式將一個單撇號的電話號碼 – JMK 2013-03-19 11:12:01
這是否有助於我的問題? 上面的代碼我寫作爲出口到Excel,有沒有其他最好的選擇呢? 我正在將數據錶轉換爲html,實際上我需要將數據導出爲excel? – Anand 2013-03-19 11:16:19