Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3012 connectés 

  FORUM HardWare.fr
  Programmation
  ASP

  [ASP] Generer un camembert Excel

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[ASP] Generer un camembert Excel

n°790113
Ulmo
Posté le 08-07-2004 à 12:04:01  profilanswer
 

Salut ,  
 
alors en fait , je cherche , apres avoir recuperer et integrer dans un tableau html des informations d'une base de donnees  , a creer un camembert afin d'avoir une bonne visualisation de mes informations .  
 
Si quelqu'un connait un bon site ou un bon faq pour utiliser les composants office ca serait cool  
 
merci d'avance
 
Ulm0  
 
 :hello:

mood
Publicité
Posté le 08-07-2004 à 12:04:01  profilanswer
 

n°793568
Ulmo
Posté le 12-07-2004 à 14:22:22  profilanswer
 

:bounce:

n°795268
Arjuna
Aircraft Ident.: F-MBSD
Posté le 13-07-2004 à 21:45:43  profilanswer
 

Je regarde si c'est jouable et je reviens :)

n°795278
Arjuna
Aircraft Ident.: F-MBSD
Posté le 13-07-2004 à 22:10:22  profilanswer
 

Ca te va ça ?
 
http://buzz.manga-torii.com/book1. [...] 8&val4=120
 
http://buzz.manga-torii.com/book1. [...] 0&val4=500
 
(change les valeurs val1, val2, val3, val4 pour modifier le camembert)


Message édité par Arjuna le 13-07-2004 à 22:22:08
n°795281
Arjuna
Aircraft Ident.: F-MBSD
Posté le 13-07-2004 à 22:16:22  profilanswer
 

Si ca te va, voici comment j'ai procédé :
 
1) J'ai créé un tableau dans une feuille Excel avec des valeurs facilement identifiables.
2) J'ai créé un pie que j'ai placé par dessus, prenant ces valeurs.
3) Enregisrter sous > Format HTML
4) Renomage en xls histoire de vérifier que ça m'ouvre bien excel avec les bonnes valeurs.
5) Renomage en asp.
 
Ajout de la ligne :


<%
Response.ContentType ="application/vnd.ms-excel"
%>


Tout en haut du code.
 
Recherche de mes valeurs bidon, et remplacement par <%=Request.QueryString("val1" )%> etc. (c'est dans un tableau HTML)
 
A la place, tu pourras mettre du code ASP qui va chercher dans la base de données les bonnes valeures.
 
Si tu ne repecte pas le nombre de lignes/colonnes de mon exemple (ce qui est certain), alors il faut modifier les lignes :
 


         <x:Value>
          <x:DataSource>0</x:DataSource>
          <x:Data>Sheet1!$B$2:$E$2</x:Data>
         </x:Value>


 
Afin de prendre le bon range.
 
PS: Tu peux ainsi faire à peut près n'importe quel document Excel, faut juste pas avoir peur du code :)
 
PS: le répertoire "Book1_Files" est inutile, mais même si tu vires la référence qui y est faite avec la balise "<link>" en haut de la page, j'ai souvenir que ça merde, donc autant la mettre.
 
En tout cas, bon courrage, parceque voilà le code de mon exemple :D
 


<%
Response.ContentType ="application/vnd.ms-excel"
%>
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
 
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<link rel=File-List href="Book1_files/filelist.xml">
<link rel=Edit-Time-Data href="Book1_files/editdata.mso">
<link rel=OLE-Object-Data href="Book1_files/oledata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
x\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>MagicBuzz</o:Author>
  <o:LastAuthor>MagicBuzz</o:LastAuthor>
  <o:Created>2004-07-13T20:02:12Z</o:Created>
  <o:LastSaved>2004-07-13T20:03:47Z</o:LastSaved>
  <o:Company>Manga-Torii</o:Company>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--table
 {mso-displayed-decimal-separator:"\.";
 mso-displayed-thousand-separator:"\,";}
@page
 {margin:1.0in .75in 1.0in .75in;
 mso-header-margin:.5in;
 mso-footer-margin:.5in;}
tr
 {mso-height-source:auto;}
col
 {mso-width-source:auto;}
br
 {mso-data-placement:same-cell;}
.style0
 {mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 white-space:nowrap;
 mso-rotate:0;
 mso-background-source:auto;
 mso-pattern:auto;
 color:windowtext;
 font-size:10.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:Arial;
 mso-generic-font-family:auto;
 mso-font-charset:0;
 border:none;
 mso-protection:locked visible;
 mso-style-name:Normal;
 mso-style-id:0;}
td
 {mso-style-parent:style0;
 padding:0px;
 mso-ignore:padding;
 color:windowtext;
 font-size:10.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:Arial;
 mso-generic-font-family:auto;
 mso-font-charset:0;
 mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 border:none;
 mso-background-source:auto;
 mso-pattern:auto;
 mso-protection:locked visible;
 white-space:nowrap;
 mso-rotate:0;}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet1</x:Name>
    <x:WorksheetOptions>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>2</x:ActiveRow>
       <x:ActiveCol>4</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetOptions>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet3</x:Name>
    <x:WorksheetOptions>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>9345</x:WindowHeight>
  <x:WindowWidth>11340</x:WindowWidth>
  <x:WindowTopX>480</x:WindowTopX>
  <x:WindowTopY>60</x:WindowTopY>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2049"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>
 
<body link=blue vlink=purple>
 
<table x:str border=0 cellpadding=0 cellspacing=0 width=448 style='border-collapse:
 collapse;table-layout:fixed;width:336pt'>
 <col width=64 span=7 style='width:48pt'>
 <tr height=17 style='height:12.75pt'>
  <td height=17 width=64 style='height:12.75pt;width:48pt' align=left
  valign=top><!--[if gte vml 1]><v:shapetype id="_x0000_t201" coordsize="21600,21600"
   o:spt="201" path="m,l,21600r21600,l21600,xe">
   <v:stroke joinstyle="miter"/>
   <v:path shadowok="f" o:extrusionok="f" strokeok="f" fillok="f"
    o:connecttype="rect"/>
   <o:lock v:ext="edit" shapetype="t"/>
  </v:shapetype><v:shape id="_x0000_s1025" type="#_x0000_t201" style='position:absolute;
   margin-left:22.5pt;margin-top:5.25pt;width:291pt;height:225pt;z-index:1'
   fillcolor="window [78]" strokecolor="windowText [77]" o:insetmode="auto">
   <v:fill color2="windowText [77]"/>
   <o:lock v:ext="edit" rotation="t" text="t"/>
   <x:ClientData ObjectType="Chart">
    <x:WebChart>
     <x:Chart>
      <x:Name>Chart 1</x:Name>
      <x:Options>
       <x:SizeWithWindow/>
      </x:Options>
      <x:PageSetup>
       <x:ChartSize>FullPage</x:ChartSize>
      </x:PageSetup>
      <x:Font>
       <x:FontName>Arial</x:FontName>
       <x:Size>10</x:Size>
       <x:AutoScale/>
      </x:Font>
      <x:Left>0</x:Left>
      <x:Top>0</x:Top>
      <x:Width>5834.99267578125</x:Width>
      <x:Height>4514.9853515625</x:Height>
      <x:ChartGrowth>
       <x:HorzGrowth>1</x:HorzGrowth>
       <x:VertGrowth>1</x:VertGrowth>
      </x:ChartGrowth>
      <x:PlotArea>
       <x:Border>
        <x:ColorIndex>None</x:ColorIndex>
       </x:Border>
       <x:Interior>
        <x:ColorIndex>None</x:ColorIndex>
       </x:Interior>
       <x:Font>
        <x:FontName>Arial</x:FontName>
        <x:Size>10</x:Size>
        <x:AutoScale/>
       </x:Font>
       <x:Graph>
        <x:Type>Pie</x:Type>
        <x:SubType>Exploded</x:SubType>
        <x:VaryColors/>
        <x:GapWidth>150</x:GapWidth>
        <x:FirstSliceAngle>0</x:FirstSliceAngle>
        <x:Series>
         <x:Index>0</x:Index>
         <x:Name>Series 1</x:Name>
         <x:Explode>11</x:Explode>
         <x:Value>
          <x:DataSource>0</x:DataSource>
          <x:Data>Sheet1!$B$2:$E$2</x:Data>
         </x:Value>
        </x:Series>
        <x:PlotVisible/>
       </x:Graph>
      </x:PlotArea>
      <x:Legend>
       <x:Delete/>
      </x:Legend>
     </x:Chart>
    </x:WebChart>
   </x:ClientData>
  </v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;
  position:absolute;z-index:1;margin-left:30px;margin-top:7px;width:389px;
  height:301px'><![endif]><![if !excel]><img width=389 height=301
  src="Book1_files/image001.gif" v:shapes="_x0000_s1025" class=shape v:dpi="96"><![endif]
 
><![if !vml]></span><![endif]><span
  style='mso-ignore:vglayout2'>
  <table cellpadding=0 cellspacing=0>
   <tr>
    <td height=17 width=64 style='height:12.75pt;width:48pt'></td>
   </tr>
  </table>
  </span></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
 </tr>
 <tr height=17 style='height:12.75pt'>
  <td height=17 style='height:12.75pt'></td>
  <td align=right x:num><%=Request.QueryString("val1" )%></td>
  <td align=right x:num><%=Request.QueryString("val2" )%></td>
  <td align=right x:num><%=Request.QueryString("val3" )%></td>
  <td align=right x:num><%=Request.QueryString("val4" )%></td>
  <td colspan=2 style='mso-ignore:colspan'></td>
 </tr>
 <tr height=289 style='height:216.75pt;mso-xlrowspan:17'>
  <td height=289 colspan=7 style='height:216.75pt;mso-ignore:colspan'></td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
  <td width=64 style='width:48pt'></td>
 </tr>
 <![endif]>
</table>
 
</body>
 
</html>


 
Il faut quelques heures pour se mettre dans le bain :D Mais c'est carrément super puissant pour faire des états à la volée quand on n'a pas Crystal Report ou autre sous la main :)
 
 
 
 
PS: Evidement, ce que je génère est un fichier Excel (au format HTML qui le rend compréhensible)
 
En aucun cas il est possible de mettre un élément office dans une page HTML (y'a des bidouilles d'invertébré, mais je t'interdit de les utiliser)
 
Si tu veux que ton pie soit directement dans le HTML, alors il va falloir passer par un composant dédié qui en fait une image à la volée. Tu peux voir un exemple sur ce site :
 
http://buzz.manga-torii.com
 
Le composant utilisé pour la version HTML (payant, mais tu trouveras pas mieu) :
 
http://www.advsofteng.com/


Message édité par Arjuna le 13-07-2004 à 22:26:34
n°796012
Ulmo
Posté le 15-07-2004 à 09:13:38  profilanswer
 

ouaa ca c'est de la reponse  :ouch:  
 
 
bon alors moi j'avais commencé à etudier un how to de chez microsoft :  
 
http://support.microsoft.com/defau [...] -us;286277
 
cette faq transformait le chart en image avant de l'afficher .
 
mais impossible d'afficher un graphique :s  
 
Apparemment d'apres ce que tu me dis l'affichage de composant office par cette methode est relativement difficile et sort de toute regle de propreté de code  :whistle:   ?  
 
Mon but etait d'afficher un camembert juste apres un tableau html . Mais à la limite si c'est impossible , je peux me retourner vers une version du fichier excel retourné qui contient les tableaux dans une feuille différente ?

n°796052
Arjuna
Aircraft Ident.: F-MBSD
Posté le 15-07-2004 à 09:53:02  profilanswer
 

Je ne connaissais âs cette méthode proposée par Microsoft. Je l'essairai un de ces 4.
 
En fait, si l'objet est capable de générer une version image du chart, à ce moment tu peux l'utiliser sans problème.
 
Par contre, il existe une autre méthode qui consiste à instancier côté client un ActiveX correspondant au contrôle Chart d'Excel. Mais cela, il ne faut absolument pas l'utiliser, car :
1) Niveau sécurité, les ActiveX c'est 0
2) Si l'utilisateur n'a pas Excel avec le composant Chart installé, ça ne marchera pas.
3) Même si l'utilisateur a Excel sur son PC, il faudra qu'il ait la même version que cette que tu utilises.
4) Caca beurk.

n°796154
jagstang
Pa Capona ಠ_ಠ
Posté le 15-07-2004 à 10:56:21  profilanswer
 

si tu veux l'usine à gaz. c'est une librairie pour .NET en C# --> XML/SVG (vectoriel)
 
Nécessite un plugin...  
 
http://msdn.microsoft.com/msdnmag/ [...] fault.aspx
 
http://msdn.microsoft.com/msdnmag/issues/03/07/ScalableVectorGraphics/fig08.gif
 
on sort un peu du cadre de départ, mais ça vaut le coup de jeter un oeil


---------------
What if I were smiling and running into your arms? Would you see then what I see now?  
n°796338
Ulmo
Posté le 15-07-2004 à 14:09:29  profilanswer
 

ok :)  
 
 
merci pour toutes ces infos  :hello:


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  ASP

  [ASP] Generer un camembert Excel

 

Sujets relatifs
Problème avec Requête SQL - ASPMacro excel
[ASP] [SQL] [ADO] paramètres de commandeAvoir le IP En ASP et le garder dans ACCES
Ajouter un projet ASP .NETtester l'existence d'une feuille Excel
Message d'excel sous VB[ASP - HTML - JS] Probleme d'impression d'une page web
[ASP][SQL][ACCESS][INSERT INTO] plusieurs enregistrements en une fois?ASP debutante lancer .bat
Plus de sujets relatifs à : [ASP] Generer un camembert Excel


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR