GridView私はテーブルをExcelにエクスポートするために使用しています。セルパディングが機能しません
私は私のコントローラでこれを持っている:
GridView gv = new GridView();
gv.DataSource = lstExportedExcel.ToList(); // lstExportedExcel does have stuff in it
gv.DataBind();
gv.HeaderRow.Cells[0].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[1].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[2].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[3].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[4].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[5].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[6].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[7].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[8].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[9].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[10].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[11].BackColor = System.Drawing.Color.LightCyan;
gv.HeaderRow.Cells[12].BackColor = System.Drawing.Color.LightCyan;
gv.CellPadding = 10; //doesn't work
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=DailySummaryExport.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gv.RenderControl(htw);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
私はこの研究を行っている、とソリューションの多くはフロントエンドにありますが、どのように私はこれが機能するのですか? Excelスプレッドシートを開くと、各セルのテキストがデフォルト境界線からパディングを取得していません。
何か助けていただければ幸いです。ここではブラインドの作業
もっと明示する必要があります。これを試してみてください: http://stackoverflow.com/questions/316931/how-to-define-cellpadding-in-gridview-in-asp- net – IrishChieftain
@IrishChieftainこの* gridview *の特定のビューはありません。このGridViewはオンザフライで作成されていますので、どのように* CSS *が動作するのですか?GridViewの* CssClassName *プロパティがあります。 –