Bonjour,

Je cherche sur le net mais je n'ai pas trouvé comment faire

Je cherche a écrire le début d'un fichier XML de type Office Excel

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<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">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Author>XXXXXXXXX</Author>
  <LastAuthor>XXXXXXXXX</LastAuthor>
  <Created>xxxx-xx-xxTxx:xx:xxZ</Created>
  <Company>XXXXXXXXX</Company>
  <Version>14.00</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <AllowPNG/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>11820</WindowHeight>
  <WindowWidth>28515</WindowWidth>
  <WindowTopX>120</WindowTopX>
  <WindowTopY>45</WindowTopY>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
 </Styles>

Je pourrais le faire avec un simple Set-Content mais j'aimerais utiliser les objets XML directement
Pour l'instant j'ai pas grand chose et je bloque déjà sur le comment écrire la ligne <?mso-application progid="Excel.Sheet"?>.

Code PowerShell : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
$doc = new-object xml
$decl = $doc.CreateXmlDeclaration("1.0", "UTF-8", $null)
$rootNode = $doc.CreateElement("Workbook");
$doc.InsertBefore($decl, $doc.DocumentElement)
$doc.AppendChild($rootNode);
$doc.Save("..........\testwrite.xml")

En vous remerciant d'avance