Reporting services

Résolu
neofenix Messages postés 145 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 11 mars 2010 - 10 juil. 2008 à 16:22
gasinho Messages postés 3 Date d'inscription vendredi 30 janvier 2009 Statut Membre Dernière intervention 3 février 2009 - 3 févr. 2009 à 09:10
Bonjour tout le monde,
Voila j'ai un petit service a vous demander ^^
Je commence a me former sur les reporting services avec visual studio 2008. Je test juste pour le moment comment afficher le rapport via des données de la base de données. Jusque la pas de problème, mais ensuite je souhaite ne plus afficher la formview et enregistrer directement mon fichier au firmat excel.
Y a t'il un moyen rapide de faire cela ou vais je devoir passer par le xml (car un rapport est avant tout un XML).
Merci d'avance.

Neofenix

4 réponses

neofenix Messages postés 145 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 11 mars 2010
15 juil. 2008 à 10:49
voici le code fonctionnel pour ceux que ca interesse

//test generation xls auto
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string deviceInfo = "<DeviceInfo><StartPage>0</StartPage></DeviceInfo>";
            string encoding;
            string extension;
            //reportViewer1.LocalReport.DataSources.Clear();
            this.USerTableAdapter.Fill(this.testDataSet.USer);
            this.reportViewer1.RefreshReport();
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("testDataSet_USer", USerTableAdapter.GetData()));
            byte[] xlsContent = reportViewer1.LocalReport.Render("Excel", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);/*Generate("Report1.rdlc", "xls");*/
            System.IO.FileStream fs = new System.IO.FileStream(@"c:\Logs\test.xls", System.IO.FileMode.Create);
            {
                fs.Write(xlsContent, 0, xlsContent.Length);
                fs.Close();
            }
3
neofenix Messages postés 145 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 11 mars 2010
11 juil. 2008 à 10:24
j'ai trouvé ceci en fouillant sur le net
public byte[] Generate(string reportPath, string format)
        {
            LocalReport localReport = new LocalReport();
            localReport.ReportPath = reportPath;

          
             // localReport.DataSources.CopyTo(reportViewer1.LocalReport.DataSources,0);

            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string deviceInfo = "<DeviceInfo><StartPage>0</StartPage></DeviceInfo>";
            string encoding;
            string extension;
            string outFormat;
            switch (format)
            {
                case "pdf":
                    outFormat = "PDF";
                    break;
                case "xls":
                    outFormat = "Excel";
                    break;
                default:
                    outFormat = "Excel";
                    break;
            }
            return localReport.Render(
                outFormat, deviceInfo, out mimeType, out encoding,
                out extension, out streamids, out warnings);
        }

mais j'ai encore un petit probleme:
 localReport.DataSources.CopyTo(reportViewer1.LocalReport.DataSources,0);
cette ligne ne fonctionne pas et je ne sais pas comment faire remplir le datasource du localreport.
Merci
0
neofenix Messages postés 145 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 11 mars 2010
11 juil. 2008 à 11:01
grosse modification ne n'ai plus de fonction
//test generation xls auto
            Warning[] warnings;
            string[] streamids;
            string mimeType;
           // string deviceInfo = "<DeviceInfo><StartPage>0</StartPage></DeviceInfo>";
            string encoding;
            string extension;
            byte[] xlsContent = reportViewer1.LocalReport.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);/*Generate("Report1.rdlc", "xls");*/
            using (System.IO.FileStream fs = new System.IO.FileStream(@"c:\Logs\test.xls", System.IO.FileMode.Create))
              {
                fs.Write(xlsContent, 0,xlsContent.Length);
                fs.Close();
              }
fichier crée avec le rapport mais sans les informations chargées a partir de sqlserver ne s'affiche pas ^^
0
gasinho Messages postés 3 Date d'inscription vendredi 30 janvier 2009 Statut Membre Dernière intervention 3 février 2009
3 févr. 2009 à 09:10
Salut,
Je voie que vous avez des connaissances avec le reporting avec le visuel studio pour ce la je vous demande de donner une ideé comment faire l'approche a un projet développer avec oracle et on vous demande de faire le reporting avec C#. C'est mon PDF donnez moi une documentation qui me permet d'avencer SVP.

Merci . 
0
Rejoignez-nous