嗨,我正在使用以下方法将数据库导出到excel
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=" + FileName);
Response.ContentType = "application/vnd.ms-excel";
EnableViewState = false;
Response.Write("<style> TABLE { border:dotted 1px #999; } TH { border:dotted 1px #D5D5D5; text-align:center } TD { border:dotted 1px #D5D5D5; } </style>");
Response.Write("<table>");
Response.Write("<tr>");
Response.Write("<th>Actual Estimated Price</th>");
Response.Write("<th>Aprroved Estimated Price </th>");
Response.Write("<th>Actual Price</th>");
Response.Write("<th>Aprroved Actual Price </th>");
Response.Write("<th>TransactionID </th>");
Response.Write("<th>Created On</th>");
Response.Write("</tr>");
foreach (DataRow dr in dt.Rows)
{
Response.Write("<tr>");
Response.Write("<td>");
Response.Write(String.Format("{0:0.0#}", dr["EstimatedPriceTotal"].ToString()));
Response.Write("</td>");
Response.Write("<td>");
Response.Write(String.Format("{0:0.0#}", dr["ApprovedEstimatedPriceTotal"].ToString()));
Response.Write("</td>");
Response.Write("<td>");
Response.Write(String.Format("{0:0.0#}", dr["ActualPriceTotal"].ToString()));
Response.Write("</td>");
Response.Write("<td>");
Response.Write(String.Format("{0:0.0#}", dr["ApprovedActualPriceTotal"].ToString()));
Response.Write("</td>");
Response.Write("<td>");
但我无法以excel格式导出excel中的实际估计价格,批准的估计价格
该值显示为5,而不是显示5.00
如何从C#端将Excel的某些列格式化为十进制格式