<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: [jdom-interest] Building and XML Spreadsheet for Microsoft Excel - Office XP Prof essional</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Hi Per</FONT>
</P>

<P><FONT SIZE=2>You a champ, this worked like a charm.</FONT>
</P>

<P><FONT SIZE=2>At the moment I am not sure if the name space is generic, especially the uuid seems a bit suspect, but I have copied the complete code here for all to use. I might be back with some more remarks once I have investigated the whole project.</FONT></P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace ns = Namespace.getNamespace(&quot;urn:schemas-microsoft-com:office:spreadsheet&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace o = Namespace.getNamespace(&quot;o&quot;,&quot;urn:schemas-microsoft-com:office:office&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace x = Namespace.getNamespace(&quot;x&quot;,&quot;urn:schemas-microsoft-com:office:excel&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace dt = Namespace.getNamespace(&quot;dt&quot;, &quot;uuid:C2F41010-65B3-11d1-A29F-00AA00C14882&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace ss = Namespace.getNamespace(&quot;ss&quot;, &quot;urn:schemas-microsoft-com:office:spreadsheet&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Namespace html = Namespace.getNamespace(&quot;html&quot;, &quot;<A HREF="http://www.w3.org/TR/REC-html40" TARGET="_blank">http://www.w3.org/TR/REC-html40</A>&quot;);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element wb = new Element(&quot;Workbook&quot;, ns);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addNamespaceDeclaration(o);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addNamespaceDeclaration(x);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addNamespaceDeclaration(dt);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addNamespaceDeclaration(ss);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addNamespaceDeclaration(html);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Document doc_out = new Document(wb);</FONT>
</P>

<P><FONT SIZE=2>Regards</FONT>
<BR><FONT SIZE=2>Ben</FONT>
</P>
<BR>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Per Norrman [<A HREF="mailto:pernorrman@telia.com">mailto:pernorrman@telia.com</A>] </FONT>
<BR><FONT SIZE=2>Sent: Thursday, November 13, 2003 1:46 PM</FONT>
<BR><FONT SIZE=2>To: 'Ben Brand'; jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: SV: [jdom-interest] Building and XML Spreadsheet for Microsoft Excel - Office XP Prof essional</FONT>
</P>
<BR>

<P><FONT SIZE=2>Hi,</FONT>
</P>

<P><FONT SIZE=2>Always used namespaces when creating elements. Add namespace declarations as necessary to the root element.</FONT>
</P>

<P><FONT SIZE=2>For example:</FONT>
<BR><FONT SIZE=2>-------------------------------------------------------------</FONT>
<BR><FONT SIZE=2>import org.jdom.Document;</FONT>
<BR><FONT SIZE=2>import org.jdom.Element;</FONT>
<BR><FONT SIZE=2>import org.jdom.Namespace;</FONT>
<BR><FONT SIZE=2>import org.jdom.output.XMLOutputter;</FONT>
</P>

<P><FONT SIZE=2>public class Excel {</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>public static void main(String[] args) throws Exception {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Namespace ns =</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Namespace.getNamespace(</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR><FONT SIZE=2>&quot;urn:schemas-microsoft-com:office:spreadsheet&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Namespace o =</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Namespace.getNamespace(</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>&quot;o&quot;,</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>&quot;urn:schemas-microsoft-com:office:office&quot;);</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>Element wb = new Element(&quot;Workbook&quot;, ns);</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addContent(new Element(&quot;OfficeStuff&quot;, o));</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb.addContent(new Element(&quot;ExcelStuff&quot;, ns));</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>wb.addNamespaceDeclaration(o);</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>new XMLOutputter(&quot;&nbsp;&nbsp; &quot;, true).output(new Document(wb),</FONT>
<BR><FONT SIZE=2>System.out);</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>/pmn</FONT>
</P>

</BODY>
</HTML>