Click here to Skip to main content
16,014,650 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: how to display the student who is in due - there are 4 rows, in 4th row he paid balance amt so i should not select that student and the who paid less than total i need to select that student Pin
sr1595-Aug-10 23:37
sr1595-Aug-10 23:37 
AnswerRe: how to display the student who is in due - there are 4 rows, in 4th row he paid balance amt so i should not select that student and the who paid less than total i need to select that student Pin
Luc Pattyn29-Jul-10 23:45
sitebuilderLuc Pattyn29-Jul-10 23:45 
AnswerRe: how to display the student who is in due - there are 4 rows, in 4th row he paid balance amt so i should not select that student and the who paid less than total i need to select that student Pin
PIEBALDconsult1-Aug-10 8:36
mvePIEBALDconsult1-Aug-10 8:36 
QuestionAbout Poweshell Pin
NetQuestions29-Jul-10 20:22
NetQuestions29-Jul-10 20:22 
AnswerRe: About Poweshell Pin
Richard MacCutchan29-Jul-10 22:19
mveRichard MacCutchan29-Jul-10 22:19 
QuestionAbout WMI Pin
NetQuestions29-Jul-10 4:03
NetQuestions29-Jul-10 4:03 
AnswerRe: About WMI Pin
dan!sh 29-Jul-10 23:11
professional dan!sh 29-Jul-10 23:11 
QuestionExport to Excel in zip format Pin
Member 322226428-Jul-10 23:01
Member 322226428-Jul-10 23:01 
Hi,
I have gridview.
I need to export the data to excel and zip it

I had used dot net zip free dll

The zip file is not having the excel.

Need help how to include the excel file in zip

the below code creates zip file

using Ionic.Zip;
using System.Text;
using System.IO;
using Ionic.Zlib;

protected void btn_Export_Click(object sender, EventArgs e)
{
HtmlForm form = new HtmlForm();
string attachment = "attachment; filename=Employee.xls";
Response.ClearContent();

Response.ContentType = "application/ms-excel";
System.IO.StringWriter stw = new System.IO.StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
form.Controls.Add(grd);
this.Controls.Add(form);
form.RenderControl(htextw);


var filesToInclude = new System.Collections.Generic.List<String>();

if (filesToInclude.Count == 0)
{
Response.Clear();
Response.BufferOutput = false;

System.Web.HttpContext c = System.Web.HttpContext.Current;
//string archiveName = String.Format("Employee.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
string archiveName = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + archiveName);
// ZipFile zip = new ZipFile();
using (ZipFile zip = new ZipFile())
{

//zip.AddFile("export.xls", "content");

zip.Encryption = EncryptionAlgorithm.WinZipAes256;

// filesToInclude is a string[] or List<String>
zip.AddFiles(filesToInclude, "files");

zip.Save(Response.OutputStream);
// zip.Save(archiveName);

}
Response.Close();

}



}

Thanks
S.Guhananth
AnswerRe: Export to Excel in zip format Pin
Eddy Vluggen28-Jul-10 23:11
professionalEddy Vluggen28-Jul-10 23:11 
GeneralRe: Export to Excel in zip format Pin
Member 322226429-Jul-10 0:59
Member 322226429-Jul-10 0:59 
GeneralRe: Export to Excel in zip format Pin
Eddy Vluggen29-Jul-10 1:04
professionalEddy Vluggen29-Jul-10 1:04 
GeneralRe: Export to Excel in zip format Pin
Member 322226429-Jul-10 1:13
Member 322226429-Jul-10 1:13 
GeneralRe: Export to Excel in zip format Pin
Eddy Vluggen29-Jul-10 1:25
professionalEddy Vluggen29-Jul-10 1:25 
AnswerRe: Export to Excel in zip format Pin
Not Active29-Jul-10 2:28
mentorNot Active29-Jul-10 2:28 
Questiondata not binding Pin
sr15928-Jul-10 0:51
sr15928-Jul-10 0:51 
QuestionProblem in Crystal report Pin
sr15928-Jul-10 0:48
sr15928-Jul-10 0:48 
QuestionHandlers removed automatically? Pin
divyesh143228-Jul-10 0:00
divyesh143228-Jul-10 0:00 
AnswerRe: Handlers removed automatically? Pin
Luc Pattyn28-Jul-10 1:13
sitebuilderLuc Pattyn28-Jul-10 1:13 
QuestionSetup project help Pin
TSWatson26-Jul-10 3:59
TSWatson26-Jul-10 3:59 
AnswerRe: Setup project help Pin
Peace ON27-Jul-10 2:27
Peace ON27-Jul-10 2:27 
QuestionCodedom Question Pin
Gavin_L25-Jul-10 18:57
Gavin_L25-Jul-10 18:57 
AnswerRe: Codedom Question Pin
Pete O'Hanlon26-Jul-10 10:05
mvePete O'Hanlon26-Jul-10 10:05 
QuestionInstall SQL Server 2008 R2 Express with my installation Pin
bonzaiholding24-Jul-10 22:28
bonzaiholding24-Jul-10 22:28 
Answercross-post Pin
Luc Pattyn25-Jul-10 2:19
sitebuilderLuc Pattyn25-Jul-10 2:19 
QuestionHow to convert a EMF file to Bitmap Pin
hawkgao012924-Jul-10 22:06
hawkgao012924-Jul-10 22:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.