Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem Reporting Services. Izvestaj u Excel file-u

[es] :: .NET :: ASP.NET :: Problem Reporting Services. Izvestaj u Excel file-u

[ Pregleda: 2335 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

B_E_N_K_O_

Član broj: 55650
Poruke: 80
195.252.99.*



+1 Profil

icon Problem Reporting Services. Izvestaj u Excel file-u21.04.2008. u 10:52 - pre 194 meseci
Imam problem. Trebam da prikazem izvestaje u Excel-u. Do sada su izvestaji bili u pdf-u i sve je bilo ok. Sada korisnice hoce da im se izvestaji otvaraju u Excelu. U pitanju je ASP.NET aplikacija i SQl Server 2005. Na racunaru je instaliran office 2007. Kada se kod izvrsi korisnici dobijaju poruku "Do you want to open or save this file" i dobijaju opcije open, save i cancel. Nakon klika na open dolazi do vrlo cudnog upozorenja "The file you are trying to open, [naziv asp.net strane], is in a different format then specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now". Nakon klika na yes sve je uredu file se otvara u excel-u. Problem je u tome sto je naziv file-a ustvari naziv asp.net strane. Evo koda:

Code:


public partial class frmIzvestaj: Page
{
        public ReportingService rs = new ReportingService();
        public SessionHeader sh = new SessionHeader();
    private void Page_PreInit(object sender, EventArgs e)
    {
       
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                string encoding;
                string mimeType;
                ParameterValue[ pars = new ParameterValue[0];
                ParameterValue[ parametersUsed;
                Warning[ warning;
                string[ streemIDS;
                byte[ data;
                string reportPath = "putanja do izvestaja";

                string devInfo = "<DeviceInfo>"+
            "<Toolbar>False</Toolbar>"+
                "<HTMLFragment>False</HTMLFragment>"+
                   " </DeviceInfo>";

                data = rs.Render(reportPath,"EXCEL",null,devInfo,pars,null,null,out encoding,
                    out mimeType,out parametersUsed,out warning,out streemIDS);
            
                this.sh.SessionId = rs.SessionHeaderValue.SessionId;

                string root = "~/Media/";
                string FileName = root + "Izvestaj" + this.Session.SessionID.ToString() + ".xls";
                string AbsoluteFileName = MapPath(FileName);

                        
                base.Response.ClearContent();

                base.Response.ClearHeaders();

                base.Response.ContentType = "application/vnd.ms-excel";

                base.Response.AddHeader("content-disposition", "attachment; filename=" + FileName);   

                base.Response.BinaryWrite(data);

                base.Response.Flush();

                base.Response.Close();

             }

 
Odgovor na temu

B_E_N_K_O_

Član broj: 55650
Poruke: 80
89.216.91.*



+1 Profil

icon Re: Problem Reporting Services. Izvestaj u Excel file-u04.05.2008. u 13:32 - pre 194 meseci
Niko nema odgovor na ovo? Niko nece cak ni da diskutuje?
 
Odgovor na temu

bgd2500

Član broj: 55912
Poruke: 226
*.adsl-1.sezampro.yu.



+7 Profil

icon Re: Problem Reporting Services. Izvestaj u Excel file-u04.05.2008. u 15:13 - pre 194 meseci
Bice da je ignorisao content-disposition u hederu, pa za naziv fajla po defaultu stavio naziv ASP stranice.
Ako se ne varam on je case-sensitive i treba da bude "Content-Disposition"
Drugo, filename u istom tom header polju stavi da je naziv fajla sa ekstenzijom ali bez putanje. Znaci probaj ovako.
Code:

base.Response.AddHeader("Content-Disposition", "attachment; filename=Izvestaj" + this.Session.SessionID.ToString() + ".xls");

 
Odgovor na temu

B_E_N_K_O_

Član broj: 55650
Poruke: 80
195.252.99.*



+1 Profil

icon Re: Problem Reporting Services. Izvestaj u Excel file-u05.05.2008. u 09:52 - pre 194 meseci
Auuu upravu si nije sljakalo samo zbog putanje. Taj red je ostao zato sto je menjana logika. Ranije je file upisivan na server pa onda slat klijentu. Mislio sam da sam to probao. Hvala

Ovaj tema bi mogla skroz da se brise ali neka ostane nekom ko ce mozda u buducnosti imati problem sa slicnim stvarima.

[Ovu poruku je menjao B_E_N_K_O_ dana 05.05.2008. u 11:15 GMT+1]
 
Odgovor na temu

[es] :: .NET :: ASP.NET :: Problem Reporting Services. Izvestaj u Excel file-u

[ Pregleda: 2335 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.