You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Zoran Avtarovski <zo...@sparecreative.com> on 2009/04/14 08:01:05 UTC

XML Data in XSSF Cell

I¹m currently working on a project where we¹re exporting data from a DB to
an Excel file. Some of the data is SVG drawing data in XML format.

There are no problems creating the xlsx file but when I try to open it,
Excel crashes.  I can¹t find any information about escaping XML for cell
content, but that¹s what I¹ve had to do.

I know that the file format is OOXML but I thought but I thought that
Excel/POI would handle any escaping and un-escaping of cell data internally.

I guess what I want to know, is this expected behaviour or is it a bug?

Z.

Re: XML Data in XSSF Cell

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
There¹s nothing to test. I add the data in the standard manner:

        this.currentRow.createCell((short)
112).setCellValue(this.escapeColumnRichText(base.getSvgData()));

where base.getSvgData() returns the xml SVG data as a string as below :
> 
> <?xml version='1.0'?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'
> 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><
> <http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> svg version='1.1'
> xmlns='http://www.w3.org/2000/svg'>
> <path fill='none' stroke='#ff0000' stroke-width='5' d='M112, 134 L112, 134,
> 113, 135, 114, 139, 105, 144, 105, 146, 106, 149, 107, 152, 109, 156, 111,
> 160, 115, 170, 117, 174, 117, 175, 117, 176, 118, 177, 118, 178, 118, 177,
> 117, 173, 117, 172, 116, 169, 116, 167, 115, 165, 114, 162, 114, 161, 113,
> 159, 112, 158, 112, 157, 112, 156'/>
> <path fill='none' stroke='#ff0000' stroke-width='5' d='M328, 134 L328, 134,
> 328, 137, 325, 145, 325, 146, 324, 146, 323, 148, 323, 150, 322, 151, 320,
> 154, 284, 156, 284, 157, 283, 158, 281, 161, 278, 163, 277, 165, 277, 166,
> 277, 167, 277, 168, 278, 169, 280, 168, 284, 166, 293, 165, 294, 165, 300,
> 165, 304, 165, 305, 165, 307, 164, 308, 163, 309, 161, 310, 160, 313, 155,
> 324, 142, 326, 137, 328, 135, 328, 134, 328, 135, 327, 147, 326, 149, 325,
> 153, 324, 156, 323, 158, 322, 159, 321, 160, 320, 160, 319, 161, 315, 164,
> 314, 165, 314, 166, 318, 169, 318, 171, 317, 172, 314, 175, 314, 176, 313,
> 177, 312, 177, 312, 178'/></svg>
> 
> 
My escapeColumn RichText does nothing more than wrap the CreationHelper
createRichTextString method as below:

        return createHelper.createRichTextString(returnString);
> 

As I said, I have no problems creating the file. I can send you a version of
the unreadable excel file if that helps.

Z.

> 
> Can you post an example of what you are doing? Ideally, it would be a sample
> program to reproduce the trouble.
> 
> Yegor
> 
>> > I¹m currently working on a project where we¹re exporting data from a DB to
>> > an Excel file. Some of the data is SVG drawing data in XML format.
>> > 
>> > There are no problems creating the xlsx file but when I try to open it,
>> > Excel crashes.  I can¹t find any information about escaping XML for cell
>> > content, but that¹s what I¹ve had to do.
>> > 
>> > I know that the file format is OOXML but I thought but I thought that
>> > Excel/POI would handle any escaping and un-escaping of cell data
>> internally.
>> > 
>> > I guess what I want to know, is this expected behaviour or is it a bug?
>> > 
>> > Z.
>> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 



Re: XML Data in XSSF Cell

Posted by Yegor Kozlov <ye...@dinom.ru>.
Can you post an example of what you are doing? Ideally, it would be a sample program to reproduce the trouble.

Yegor

> I¹m currently working on a project where we¹re exporting data from a DB to
> an Excel file. Some of the data is SVG drawing data in XML format.
> 
> There are no problems creating the xlsx file but when I try to open it,
> Excel crashes.  I can¹t find any information about escaping XML for cell
> content, but that¹s what I¹ve had to do.
> 
> I know that the file format is OOXML but I thought but I thought that
> Excel/POI would handle any escaping and un-escaping of cell data internally.
> 
> I guess what I want to know, is this expected behaviour or is it a bug?
> 
> Z.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org