要更改excel的数字格式

时间:2015-04-02 14:56:08

标签: c# asp.net

如何在asp.net中从网格导出时更改excel的数量。 在网格中,值显示200.00或0.00在excel中显示200或0.我希望显示为200.00或0.00。

这是我正在使用的代码:

HtmlForm form = new HtmlForm();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", "Supply/DemandReport.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gdSupplyorDemand.AllowPaging = false;
gdSupplyorDemand.HeaderStyle.ForeColor = System.Drawing.Color.Black;
int location = int.Parse( ddlLocation.SelectedValue);
int ProductType = int.Parse(dpProductType.SelectedValue);
MastersClient DemandReport = new MastersClient();
DataSet ds = DemandReport.GetSupplyorDemandReport(ProductType, location);
gdSupplyorDemand.DataSource = ds.Tables[0];
gdSupplyorDemand.DataBind();
form.Attributes["runat"] = "server";
form.Controls.Add(gdSupplyorDemand);
this.Controls.Add(form);
form.RenderControl(hw);
string style = @"<style> .textmode { mso-number-form at:\@;}</style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();

0 个答案:

没有答案