xlsxAdd and Namespace issue



  • I have a scenario where i want to reuse an image within my Excel spreadsheet. In the sheet I have an image (red/yellow/green circle for status). Rather than use xlsxAddImage which will create a copy of the image X number of times, I have created an Excel Template that has the image in there once and then I am using the twoCellAnchor concept and referencing the same image by rID#. This works fine when working with OpenXML and verifying everything in the Office productivity tool. However, since this is in a different namespace than the original x: used in Row, it seems that the xlsxAdd has a big issue here. Not sure why, but it's not working. here's what I am seeing.

    First, I would normally thing i would reference it by doing {{#xlsxAdd "xl/drawings/drawing1.xml" "wsDr.twoCellAnchor"}}, but instead I have to do {{#xlsxAdd "xl/drawings/drawing1.xml" "xdr:wsDr.twoCellAnchor"}} otherwise it creates another XML node without the namespace. This is not an issue, but is slightly odd.

    Second (and the real issue) is that my content should be something like
    <xdr:twoCellAnchor editAs="oneCell" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing">
    ...
    </xdr:twoCellAnchor>

    However, the result in the file generated strips out the xdr: from the node. This is causing Excel to not render anything (as well as the productivity tool not knowing what type of node it is). I have also tried
    <xdr:twoCellAnchor editAs="oneCell">
    and that didn't help anything.

    Any help I can get on handling the namespace appropriately would be appreciated.



  • You're really doing big things with xlsx recipe. That is great.

    but instead I have to do {{#xlsxAdd "xl/drawings/drawing1.xml" "xdr:wsDr.twoCellAnchor"}} otherwise it creates another XML node without the namespace. This is not an issue, but is slightly odd.

    That looks ok to me, why it's odd?

    However, the result in the file generated strips out the xdr: from the node.

    It looks like that for me the xdr isn't stripped. Could you check it here?
    https://playground.jsreport.net/w/anon/GzP_qRYw



  • You solved my issue!!!

    The reason I thought it was odd was because I actually had the wrong syntax

    In my example i was doing {{#xlsxAdd "xl/drawings/drawing1.xml" "xdr:wsDr.twoCellAnchor"}}

    In your example you did {{#xlsxAdd "xl/drawings/drawing1.xml" "xdr:wsDr.xdr:twoCellAnchor"}}

    I completely missed the 2nd namespace which is what caused things to not work at all. This is why things looked odd to me but I couldn't figure out why.

    As always...thanks for everything! It's a great product!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.