Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Carriage returns in XML Excel sheet created using XmlDocument and XmlTextWriter

Reply
Thread Tools

Carriage returns in XML Excel sheet created using XmlDocument and XmlTextWriter

 
 
st@jpa.co.jp
Guest
Posts: n/a
 
      10-07-2005
Hi,

I've a routine that exports a DB query to Excel by building an
XmlDocument and saving to a XmlTextWriter. I'm having trouble with
carriage returns in a mailing address not showing up in the final Excel
sheet.

What's added to the InnerText of an XmlDocument is something similar
to:

"Name \r\nAddress1\r\nAddress2 \r\nAddress3 \r\nAddress4\r\n"

After going through the XmlTextWriter the resulting XML is:

</Data></Cell><Cell ss:StyleID="s26"><Data ss:Type="String">
Name
Address1
Address2
Address3
Address4

And what appears in the address cell of the Excel sheet is:
Name Address1 Address 2 Address 3 Address 4

I posted a similar topic yesterday and spent much of today working on
the issue without success, trying out various combinations of:
space = "preserve" in the XML
XmlDocument.PreserveWhitespace = true
XmlTextWriter.WriteAttributeString("xml", "space", null, "preserve");

Can anyone assist?

Many thanks,

Simon Lane

 
Reply With Quote
 
 
 
 
Martin Dechev
Guest
Posts: n/a
 
      10-07-2005
Hi,

An ugly solution, but it's a problem of Excel I think - try replacing in
your xml Environment.NewLine with "\n" or VbLf for C# and VB.NET
respectively.

Hope This Helps
Martin Dechev
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> I've a routine that exports a DB query to Excel by building an
> XmlDocument and saving to a XmlTextWriter. I'm having trouble with
> carriage returns in a mailing address not showing up in the final Excel
> sheet.
>
> What's added to the InnerText of an XmlDocument is something similar
> to:
>
> "Name \r\nAddress1\r\nAddress2 \r\nAddress3 \r\nAddress4\r\n"
>
> After going through the XmlTextWriter the resulting XML is:
>
> </Data></Cell><Cell ss:StyleID="s26"><Data ss:Type="String">
> Name
> Address1
> Address2
> Address3
> Address4
>
> And what appears in the address cell of the Excel sheet is:
> Name Address1 Address 2 Address 3 Address 4
>
> I posted a similar topic yesterday and spent much of today working on
> the issue without success, trying out various combinations of:
> space = "preserve" in the XML
> XmlDocument.PreserveWhitespace = true
> XmlTextWriter.WriteAttributeString("xml", "space", null, "preserve");
>
> Can anyone assist?
>
> Many thanks,
>
> Simon Lane
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Excel sheet from asp.net returns empty cell =?Utf-8?B?ZGF2ZQ==?= ASP .Net 2 09-05-2009 04:08 AM
read a excel sheet using aspose.excel sajithkahawatta ASP .Net 3 04-19-2007 02:54 PM
Re: Can an XmlNode from one XmlDocument be copied to another XmlDocument? Bob ASP .Net 0 07-21-2004 11:49 PM
Help: Delete a single carriage return in a file, but not a double carriage return? Steve Anderson Perl Misc 3 06-21-2004 12:48 AM
loading xmlcontent from one xmldocument into another xmldocument Shoval Tomer ASP .Net 0 07-09-2003 04:29 PM



Advertisments