私はグリッドビューでasp.netページに取り組んでいます。グリッドビューを Excel にエクスポートする必要がありますが、エクスポートする前に列データを変更する必要があります。以下のコードを使用してエクスポートしています。
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.ContentType = "application/vnd.xls";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
gvLogs.RenderControl(hw);
gvLogs.AllowPaging = false;
gvLogs.DataBind(); // bind data
Response.Output.Write(sw.ToString());
//need to call Flush and End methods
Response.Flush();
Response.End();
それは機能しますが、グリッドを次のようにグリッドと同じ列データでExcelにエクスポートします。
asif@cc.com my company1aa viewed profile abc@gmail.com my name Company views profile 7/24/2013 11:18
asif@cc.com my company1aa viewed profile cv3@cc.com cv 3 Company views profile 7/24/2013 11:18
asif@cc.com my company1aa viewed profile cv2@cc.com cv 2 Company views profile 7/24/2013 11:17
asif@cc.com my company1aa viewed profile cv4@cc.com cv 4 Company views profile 7/24/2013 11:17
asif@cc.com my company1aa viewed profile CV1@cc.com cv 1 Company views profile 7/24/2013 11:16
最初の列を4列に分割したい(最初の行の場合)
Employer email = asif@cc.com
company name = my company1aa
Registrant email = abc@gmail.com
Full name = my name
and then remaining 2 columns as it is
Action = Compnay view Profile
Date = 7/24/2013 11:18
これを行う方法を提案してください。バインドにオブジェクト データ ソースを使用していますが、データ テーブルを取得できます。
HRActionLog actionLog = new HRActionLog();
DataTable dt = actionLog.GetList(Action,DateFrom,DateTo,CompanyId,RegistrantId,VacancyId,CurrentLanguage);
追加の列を含む新しいデータテーブルを作成し、 dt から入力する必要がありますか?
提案してください