Dear all,
I am using below code snippet to download an excel file in our website.
but my problem is : I have to download a password protected and encrypted excel file and decrypt it using any windows based software.
please help me to solve this problem.
Any type of help is highly appreciable.
Thanks in advance.....
string strQuery = @"select
TSPR.Student_Code,
TSPR.Account_No,
isnull(TSED.Scholarship_Second,TSED.Scholarship_First) as [Amount],
(TSPR.First_Name+' '+TSPR.Middle_Name+' '+TSPR.Last_Name) as [Name],
TSPR.Mobile,TDD.Disbursal_No As [Disbursal No],
TSPR.Bank_Name,
TSPR.IFSC_Code,
tdm.Dist_Name,
tBM.Block_Name,
TSM.School_Name
from tbl_Disbursal_Details TDD
inner join tbl_Proposal_Detail TPD
on TPD.Proposal_No = SUBSTRING(Disbursal_No,19,4)+ '/' +SUBSTRING(Disbursal_No,3,10) + '/' +SUBSTRING(Disbursal_No,14,1)+ '/' +SUBSTRING(Disbursal_No,16,2) + '/' + SUBSTRING(Disbursal_No,24,2)
inner join tbl_Proposal_Master TPM
on TPM.Proposal_No = tpd.Proposal_No
inner join tbl_Student_Personal_Registration TSPR
on TSPR.Student_Code = TPM.Student_Code
inner join tbl_Student_Educational_Details TSED
on TSED.Student_Code = TSPR.Student_Code and TSED.School_Code = TSPR.School_Code
inner join tbl_Dist_Master TDM
on TDM.Dist_Code = SUBSTRING(TDD.Disbursal_No,5,2)
inner join tbl_Block_Master TBM
on TBM.Dist_Code = TDm.Dist_Code and TBM.Block_Code = SUBSTRING(TDD.Disbursal_No,7,2)
inner join tbl_School_Master TSM
on tsm.School_Code = SUBSTRING(TDD.Disbursal_No,3,10)
where Disbursal_No = @DisNo And TPM.flag_Rejected_ByBank = 0 ";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.Parameters.Add("@DisNo", SqlDbType.NVarChar).Value = DNo;
DataTable dt = GetData(cmd);
GridView GridView1 = new GridView();
GridView1.AllowPaging = false;
GridView1.DataSource = dt;
GridView1.DataBind();
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + DNo + ".xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
for (int i = 0; GridView1.Rows.Count; i++)
{
GridView1.Rows[i].Attributes.Add("class", "textmode");
}
GridView1.RenderControl(hw);
string style = @".textmode { mso-number-format:";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.End();