je le schéma XML suivant:ASP.NET: Comment convertir schéma pour Excel xsl
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0">
<xs:element name="PercentTimeReport">
<xs:complexType>
<xs:sequence>
<xs:element name="ParamStartDate" type="xs:dateTime" />
<xs:element name="ParamEndDate" type="xs:dateTime" />
<xs:element name="ParamQuarterInt" type="xs:unsignedByte" />
<xs:element name="ParamProjID" nillable="true" />
<xs:element name="ParamStaffID" nillable="true" />
<xs:element name="ParamPercentRange" type="xs:unsignedByte" />
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Item">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:unsignedShort" />
<xs:element name="EmployeeName" type="xs:string" />
<xs:element name="StaffID" type="xs:unsignedShort" />
<xs:element name="Status" type="xs:string" />
<xs:element name="Date" type="xs:dateTime" />
<xs:element name="Department" type="xs:string" />
<xs:element name="DepartmentCode" type="xs:string" />
<xs:element name="Project" type="xs:string" />
<xs:element name="ProjectID" type="xs:unsignedByte" />
<xs:element name="Hours" type="xs:unsignedByte" />
<xs:element name="HoursPerWeek" type="xs:decimal" />
<xs:element name="PercentTime" type="xs:decimal" />
<xs:element name="ActualContact" type="xs:boolean" />
<xs:element name="Body" type="xs:string" />
<xs:element name="Issue" type="xs:string" />
<xs:element name="Activity" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xsd:schema>
et je voudrais générer un fichier Excel qui affiche uniquement la table des éléments dans un ASP.NET 2.0 Application Web. Je ne comprends vraiment pas ce code that I found (voir ci-dessous), ou XSLT assez pour obtenir le format de sortie dont j'ai besoin. Est-ce que quelqu'un sait XSLT, qui pourrait me dire comment modifier le XSLT ci-dessous pour:
1) Masquer les éléments autres que les éléments (par exemple ParamStartDate, ParamEndDate, etc.).
2) Sortie de la table avec l'élément complexe "Items" imbriqué.
Actuellement, le xsl ci-dessous produit chacun des éléments comme en-têtes de colonne, et la cellule Items contient tous les éléments sur une ligne. J'ai essentiellement besoin d'aller un niveau plus profond.
<xsl:template match="/">
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:apply-templates/>
</Workbook>
</xsl:template>
<xsl:template match="/*">
<Worksheet>
<xsl:attribute name="ss:Name">
<xsl:value-of select="local-name(/*/*)"/>
</xsl:attribute>
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<xsl:for-each select="*[position() = 1]/*">
<Cell>
<Data ss:Type="String">
<xsl:value-of select="local-name()"/>
</Data>
</Cell>
</xsl:for-each>
</Row>
<xsl:apply-templates/>
</Table>
</Worksheet>
</xsl:template>
<xsl:template match="/*/*">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>
<xsl:template match="/*/*/*">
<Cell>
<Data ss:Type="String">
<xsl:value-of select="."/>
</Data>
</Cell>
</xsl:template>
sortie Excel souhaité (uniquement afficher les éléments complexType comme tableau):
ID EmployeeName StaffID .... Issue Activity 1 John Smith 231 .... text text 2 Kate Henderson 101 .... text2 text3 . .... . .... N ....
Courant de sortie:
ParamStartDate ParamEndDate .... ParamPercentRange Items '01/01/2010' '04/01/2010' .... 6 '1John Smith231...texttext....'
Comme toujours, toute aide grandement appréciée.
Merci
P.S. Alejandro, voici la sortie avec vos modifications:
<?xml version="1.0" encoding="utf-8"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="PercentTimeReport">
<Table x:FullColumns="1" x:FullRows="1">
<Row />
</Table>
</Worksheet>
</Workbook>
Voici un échantillon de ma sortie d'origine:
<?xml version="1.0" encoding="utf-8"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts">
<Worksheet ss:Name="PercentTimeReport">
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">ParamStartDate</Data></Cell><Cell><Data ss:Type="String">ParamEndDate</Data></Cell><Cell><Data ss:Type="String">ParamQuarterInt</Data></Cell><Cell><Data ss:Type="String">ParamPercentRange</Data></Cell><Cell><Data ss:Type="String">Items</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">2010-07-01T00:00:00</Data></Cell><Cell><Data ss:Type="String">2010-09-30T00:00:00</Data></Cell>....</Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
S'il vous plaît noter que vous devez mettre en retrait le code par 4 espaces (par exemple en cliquant sur le bouton de la barre d'outils correspondant). Sinon, le code XML ne sera pas visible. –
Bien sûr, j'ai juste besoin de produire un fichier Excel avec une seule feuille contenant les colonnes suivantes: ID, EmployeeName, StaffID, Statut, Date, Département, DepartmentCode, Projet, ProjectID, Heures, TotalHours, HoursPerWeek, PercentTime, ActualContactCount, ActualContactFlag, Corps, problème, activité. – Sephrial
Actuellement, il crée une table avec des colonnes: ParamStartDate, ParamEndDate, ..., Items. – Sephrial