asp.net - How to protect password in Excel while downloading? -


How to protect passwords in Excel when downloading excel file

this.Response.AddHeader (" Content-displacement "," attachment; file name = report with history. Xls "); This.Response.ContentType = "app / vnd.ms-excel"; Byte [] buffer = System.Text.Encoding.UTF8.GetBytes (sb.ToString ()); Finally I got the code:

  Secure zero page_load (object) Sender, EventErgues e) {DataSetToExcel (GetDataSet (), False); } Private Static Dataset GetDataSet () {DataSet ds = new DataSet (); System.Data.DataTableDT = New System.Data.DataTable ("Table"); Dt.Columns.Add ("name", Type.GetType ("System.String")); Dt.Columns.Add ("Address", Type.GetType ("System.String")); Dt.Columns.Add ("Phone", Type.GetType ("System.String")); Datarov Dr. = DT. NRO (); Dr. ["name"] = "Balaji Selvarjan"; Dr. ["address"] = "Reddysur"; Dr. ["phone"] = "000 -0,000"; Dt.Rows.Add (Dr.); Dr = dt.NewRow (); Dr. ["name"] = "Balaji S"; Dr. ["address"] = "Kuttumannar coil"; Dr. ["phone"] = "000 -0,000"; Dt.Rows.Add (Dr.); Ds.Tables.Add (DT); Return ds; } Private static blank datasettoxcel (dataset DS, Boolean generative integrity) {Microsoft.Office.Interop.Excel.Application xlApp = New Microsoft.Office.Interop.Excel.Application (); XlApp.Visible = false; Microsoft.Office.Interop.Excel.Workbook wb = xlApp.Workbooks.Add (XlWBATemplate.xlWBATWorksheet); (Int k = 0; k & lt; ds.Tables.Count; k ++) {System.Data.DataTable = DT = DTibles}; Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet) wb.Worksheets.Add (missing value, unavailable value, lost value, lost value); Ws.Name = dt.TableName; For (int i = 0; i & lt; dt.rows.Count; i ++) {for (int j = 0; j & lt; dt.Columns.Qount; j ++) {if (i = = 0) ws.Cells [1, J + 1] = DT. Column [ja]. Column name; Ws.Cells [i + 2, j + 1] = (which generates == 0 & amp; generator)? (I + 1) .Ostring (): DT. Ro [ii] [ja]. Ostring (); }} Ws.Protect ("1", true, true, true, true, true, true, true, true, true, true, true, true); } Wb.Protect ("my", true, true); Wb.Password = "test"; Wb.Close (); XlApp.Visible = true; }  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -