AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

XML-File die zweite, Kindeskinder?

Ein Thema von khh · begonnen am 25. Jun 2015 · letzter Beitrag vom 27. Jun 2015
Antwort Antwort
Seite 1 von 2  1 2      
khh

Registriert seit: 18. Apr 2008
Ort: Südbaden
1.903 Beiträge
 
FreePascal / Lazarus
 
#1

XML-File die zweite, Kindeskinder?

  Alt 25. Jun 2015, 07:59
Hallo zusammen,
mit
Delphi-Quellcode:
 doc := TXMLDocument.Create;
      try
         doc.XMLVersion := '1.0';
         doc.AppendChild(doc.CreateProcessingInstruction('mso-application', 'progid="Excel.Sheet"'));

         nRoot := doc.CreateElement('Workbook');
         TDOMElement(nRoot).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:spreadsheet');
         TDOMElement(nRoot).SetAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
         TDOMElement(nRoot).SetAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
         TDOMElement(nRoot).SetAttribute('xmlns:ss', 'urn:schemas-microsoft-com:office:spreadsheet');
         TDOMElement(nRoot).SetAttribute('xmlns:html', 'http://www.w3.org/TR/REC-html40');
         doc.AppendChild(nRoot);

         nDocProperties := doc.CreateElement('DocumentProperties');
         TDOMElement(nDocProperties).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:office');
         nRoot.AppendChild(nDocProperties);

         AddTextNode(nDocProperties, 'Author', 'ich');
         AddTextNode(nDocProperties, 'LastAuthor', 'ich');
         AddTextNode(nDocProperties, 'Created', FormatDateTime('yyyy-mm-dd', Now) + 'T' + FormatDateTime('hh:nn:ss', Now) + 'Z');
         AddTextNode(nDocProperties, 'Version', '15.0');

         nDocSettings := doc.CreateElement('OfficeDocumentSettings');
         TDOMElement(nDocSettings).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:office');
         nRoot.AppendChild(nDocSettings);

         nDocSettings.AppendChild(doc.CreateElement('AllowPNG'));
         //////////////////////////
         nDocSettings := doc.CreateElement('ExcelWorkbook');
         TDOMElement(nDocSettings).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:excel');
         nRoot.AppendChild(nDocSettings);
         AddTextNode(nDocSettings, 'WindowHeight', '12435');
         AddTextNode(nDocSettings, 'WindowWidth', '2880');
         AddTextNode(nDocSettings, 'WindowTopX', '0');
         AddTextNode(nDocSettings, 'WindowTopY', '0');
         AddTextNode(nDocSettings, 'ProtectStructure', 'False');
         AddTextNode(nDocSettings, 'ProtectWindows', 'False');
         ////////////////////////////
         nDocSettings := doc.CreateElement('Styles');

         nChild:= nDocSettings.AppendChild(doc.CreateElement('Style'));
         TDOMElement(nChild).SetAttribute('ss:ID', 'Default');
         TDOMElement(nChild).SetAttribute('ss:Name', 'Normal');

         nRoot.AppendChild(nDocSettings);
...
...
erstelle ich folgendes Fragment:

Delphi-Quellcode:
<?xml version="1.0" encoding="utf-8"?>
<?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>ich</Author>
    <LastAuthor>ich</LastAuthor>
    <Created>2015-06-25T08:50:13Z</Created>
    <Version>15.0</Version>
  </DocumentProperties>
  <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
    <AllowPNG/>
  </OfficeDocumentSettings>
  <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    <WindowHeight>12435</WindowHeight>
    <WindowWidth>2880</WindowWidth>
    <WindowTopX>0</WindowTopX>
    <WindowTopY>0</WindowTopY>
    <ProtectStructure>False</ProtectStructure>
    <ProtectWindows>False</ProtectWindows>
  </ExcelWorkbook>
  <Styles>
    <Style ss:ID="Default" ss:Name="Normal"/>
  </Styles>
</Workbook>
dafür vielen Dank an CCRDude

inner halb des Style-Nodes benötige ich weiter Kind-Notes, wie krieg ich das hin?
Ich verzweifle gerade, wenn ich mir dazu das ganze XML DOM-Tutorial durcharbeiten muss

so soll das Style-Fragment werden:

Delphi-Quellcode:
<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>
    <Style ss:ID="s62">
      <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="20" ss:Color="#000000" ss:Bold="1" />
    </Style>
</Styles>
ich danke euch gewaltig für eure Hilfen
Karl-Heinz
  Mit Zitat antworten Zitat
Benutzerbild von BUG
BUG

Registriert seit: 4. Dez 2003
Ort: Cottbus
2.094 Beiträge
 
#2

AW: XML-File die zweite, Kindeskinder?

  Alt 25. Jun 2015, 09:08
Die Lösung steht quasi in deinem Quellcode
Du hast doch schon Kindeskinder (Workbook>Styles>Style). Wie hast du denn Style zu Styles hinzugefügt?
  Mit Zitat antworten Zitat
khh

Registriert seit: 18. Apr 2008
Ort: Südbaden
1.903 Beiträge
 
FreePascal / Lazarus
 
#3

AW: XML-File die zweite, Kindeskinder?

  Alt 25. Jun 2015, 09:34
Hallo Robert,
Style hab ich per

  nChild:= nDocSettings.AppendChild(doc.CreateElement('Style')); hinzugefügt, aber jetzt steh ich irgendwie auf dem Schlauch

nDocSettings.AppendChild(nchild.CreateElement('Fon t'));

funktioniert nicht
Karl-Heinz
  Mit Zitat antworten Zitat
Benutzerbild von BUG
BUG

Registriert seit: 4. Dez 2003
Ort: Cottbus
2.094 Beiträge
 
#4

AW: XML-File die zweite, Kindeskinder?

  Alt 25. Jun 2015, 09:40
nDocSettings.AppendChild(nchild.CreateElement('Font')); funktioniert nicht
Lass mich raten ... das fügt das "Font"-Element dem "Styles"-Element hinzu?
Du must das Kind schon an den richtigen Knoten anhängen. Vermutlich steht das Element schon in einer Variable ... nur in welcher?
Tipp: Du hast schon Attribute zu dem Element hinzugefügt.

Geändert von BUG (25. Jun 2015 um 10:19 Uhr)
  Mit Zitat antworten Zitat
khh

Registriert seit: 18. Apr 2008
Ort: Südbaden
1.903 Beiträge
 
FreePascal / Lazarus
 
#5

AW: XML-File die zweite, Kindeskinder?

  Alt 25. Jun 2015, 10:39
tut mir leid, ich blicks gerade nicht
Karl-Heinz
  Mit Zitat antworten Zitat
khh

Registriert seit: 18. Apr 2008
Ort: Südbaden
1.903 Beiträge
 
FreePascal / Lazarus
 
#6

AW: XML-File die zweite, Kindeskinder?

  Alt 27. Jun 2015, 15:25
Hallo zusammen, hallo BUG,
danke für den Denkanstoss. Man muss manchmal nur richtig wach sein

so funktionierts:

Delphi-Quellcode:
 doc.XMLVersion := '1.0';
         doc.AppendChild(doc.CreateProcessingInstruction('mso-application', 'progid="Excel.Sheet"'));

         nRoot := doc.CreateElement('Workbook');
         TDOMElement(nRoot).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:spreadsheet');
         TDOMElement(nRoot).SetAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
         TDOMElement(nRoot).SetAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
         TDOMElement(nRoot).SetAttribute('xmlns:ss', 'urn:schemas-microsoft-com:office:spreadsheet');
         TDOMElement(nRoot).SetAttribute('xmlns:html', 'http://www.w3.org/TR/REC-html40');
         doc.AppendChild(nRoot);

         nDocProperties := doc.CreateElement('DocumentProperties');
         TDOMElement(nDocProperties).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:office');
         nRoot.AppendChild(nDocProperties);

         AddTextNode(nDocProperties, 'Author', 'ich');
         AddTextNode(nDocProperties, 'LastAuthor', 'ich');
         AddTextNode(nDocProperties, 'Created', FormatDateTime('yyyy-mm-dd', Now) + 'T' + FormatDateTime('hh:nn:ss', Now) + 'Z');
         AddTextNode(nDocProperties, 'Version', '15.0');

         nDocSettings := doc.CreateElement('OfficeDocumentSettings');
         TDOMElement(nDocSettings).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:office');
         nRoot.AppendChild(nDocSettings);

         nDocSettings.AppendChild(doc.CreateElement('AllowPNG'));
         //////////////////////////
         nDocSettings := doc.CreateElement('ExcelWorkbook');
         TDOMElement(nDocSettings).SetAttribute('xmlns', 'urn:schemas-microsoft-com:office:excel');
         nRoot.AppendChild(nDocSettings);
         AddTextNode(nDocSettings, 'WindowHeight', '12435');
         AddTextNode(nDocSettings, 'WindowWidth', '2880');
         AddTextNode(nDocSettings, 'WindowTopX', '0');
         AddTextNode(nDocSettings, 'WindowTopY', '0');
         AddTextNode(nDocSettings, 'ProtectStructure', 'False');
         AddTextNode(nDocSettings, 'ProtectWindows', 'False');
         ////////////////////////////
         nDocSettings := doc.CreateElement('Styles');

         nChild:= nDocSettings.AppendChild(doc.CreateElement('Style'));
         TDOMElement(nChild).SetAttribute('ss:ID', 'Default');
         TDOMElement(nChild).SetAttribute('ss:Name', 'Normal');

          nRoot.AppendChild(nDocSettings);
          nChildChild:= nChild.AppendChild(doc.CreateElement('Alignment'));
          TDOMElement(nChildChild).SetAttribute('ss:Vertical', 'Bottom');
          nChildChild:= nChild.AppendChild(doc.CreateElement('Borders'));
          nChildChild:= nChild.AppendChild(doc.CreateElement('Font'));
          TDOMElement(nChildChild).SetAttribute('ss:FontName', 'Calibri');
          TDOMElement(nChildChild).SetAttribute('ss:Family', 'Swiss');
          TDOMElement(nChildChild).SetAttribute('ss:Size', '11');
          TDOMElement(nChildChild).SetAttribute('ss:Color', '#000000');

          nChildChild:= nChild.AppendChild(doc.CreateElement('Interior'));
          nChildChild:= nChild.AppendChild(doc.CreateElement('NumberFormat'));
          nChildChild:= nChild.AppendChild(doc.CreateElement('Protection'));
mit diesem Ergebnis:

Delphi-Quellcode:
<?xml version="1.0" encoding="utf-8"?>
<?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>ich</Author>
    <LastAuthor>ich</LastAuthor>
    <Created>2015-06-27T16:21:35Z</Created>
    <Version>15.0</Version>
  </DocumentProperties>
  <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
    <AllowPNG/>
  </OfficeDocumentSettings>
  <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    <WindowHeight>12435</WindowHeight>
    <WindowWidth>2880</WindowWidth>
    <WindowTopX>0</WindowTopX>
    <WindowTopY>0</WindowTopY>
    <ProtectStructure>False</ProtectStructure>
    <ProtectWindows>False</ProtectWindows>
  </ExcelWorkbook>
  <Styles>
    <Style ss:ID="Default" ss:Name="Normal">
      <Alignment ss:Vertical="Bottom"/>
      <Borders/>
      <Font ss:Size="11" ss:Color="#000000" ss:Family="Swiss" ss:FontName="Calibri"/>
      <Interior/>
      <NumberFormat/>
      <Protection/>
    </Style>
  </Styles>
</Workbook>
Karl-Heinz
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#7

AW: XML-File die zweite, Kindeskinder?

  Alt 27. Jun 2015, 15:46
schemas-microsoft-comffice:spreadsheet? Willst du die xte "Ich kann xlsx-Dateien selbst schreiben"-Klasse entwickeln?
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
khh

Registriert seit: 18. Apr 2008
Ort: Südbaden
1.903 Beiträge
 
FreePascal / Lazarus
 
#8

AW: XML-File die zweite, Kindeskinder?

  Alt 27. Jun 2015, 15:53
schemas-microsoft-comffice:spreadsheet? Willst du die xte "Ich kann xlsx-Dateien selbst schreiben"-Klasse entwickeln?
wenns nicht sein muss, natürlich nicht.
Ich hab aber keine "fertige" Lösung gefunden

Hast du eine ?

Gruss KHH
Karl-Heinz
  Mit Zitat antworten Zitat
Benutzerbild von Bernhard Geyer
Bernhard Geyer

Registriert seit: 13. Aug 2002
17.171 Beiträge
 
Delphi 10.4 Sydney
 
#9

AW: XML-File die zweite, Kindeskinder?

  Alt 27. Jun 2015, 16:04
schemas-microsoft-comffice:spreadsheet? Willst du die xte "Ich kann xlsx-Dateien selbst schreiben"-Klasse entwickeln?
wenns nicht sein muss, natürlich nicht.
Ich hab aber keine "fertige" Lösung gefunden

Hast du eine ?

Gruss KHH
Mehrere. Die Frage ist

Darf was Kosten?
Darf Excel installiert sein?
Delphi und/oder Lazarus?
Windows Vista - Eine neue Erfahrung in Fehlern.
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#10

AW: XML-File die zweite, Kindeskinder?

  Alt 27. Jun 2015, 16:06
Nach ein paar Sekunden Websuche bin ich schon auf folgende Produkte gestoßen:

http://libxl.com/home.html
www.kluug.net/xlsx-ods-delphi.php
http://bytescout.com/products/develo...dsheetsdk.html
Markus Kinzler
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz