I need to to export excel with password from Grid view . I am using following Code for same
Java
public ActionResult DataExportExcel(GridView GridView1, string FileName, int FontSize)
{
GridView1.Font.Size = FontSize;
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView dataGridView1 = new GridView();
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + FileName.Trim() + ".xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
int RowCount= GridView1.Rows.Count;
for (int i = 0; i // GridView1.Rows[i].Attributes.Add("class", "textmode");
GridView1.Rows[i].Height = 33;
GridView1.Rows[i].Cells[5].Wrap = false;
GridView1.Rows[i].Cells[5].Style.Add("mso-number-format", TestFormat(GridView1.Rows[i].Cells[5].Text.Length));
}
GridView1.Rows[RowCount-1].Cells[3].Font.Bold = true;
GridView1.Rows[RowCount - 1].Cells[4].Font.Bold = true;
GridView1.RenderControl(hw);
GridView1.HeaderStyle.Height = 33;
GridView1.FooterStyle.Height = 33;
dataGridView1 = GridView1;
Response.Output.Write(Convert.ToString(sw));
Response.Flush();
Response.End();Code
Code
return View();
}Code
Code
Code
So pls Help me
Manas MohapatraRank #182 · 13.2K reputationPosted Apr 6, 2016, 10:40 PM EDT
vimalendu kuamar121 reputationPosted Apr 7, 2016, 12:50 AM EDT
sir
I want set password on Downloaded Excel
alice yangRank #2,329 · 607 reputationPosted Apr 7, 2016, 7:56 PM EDT