none
About OpenXml's ShapeId RRS feed

  • Question

  • I find that there are two files in an excel file, and two images of them have the same number of "Shape Id", which causes the error.

    Anyone help me, please.

    :)

    • Edited by Decker Dong - MSFT Tuesday, January 8, 2013 5:20 AM Non-existing in Chinese Forum, Move to English
    • Moved by Decker Dong - MSFT Tuesday, January 8, 2013 5:21 AM OpenXML problem (From:XML 与 Web Services 讨论区)
    Monday, January 7, 2013 9:40 AM

Answers

  • The amount of information you provide is still very small. I suspect we're dealing with the language barrier, to a certain extent... Let me try repeating back what I understand your problem to be and you confirm or correct it:

    • You have an Excel workbook that you're using Open XML SDK to analyze.
    • This workbook has multiple worksheets, and more than one of the worksheets has Shape objects on the surface.
    • Excel starts the numbering for the Shape ID value on each sheet with 1 (one), so it's possible that more than one Shape in the workbook has the same Shape ID
    • This is causing problems when you try to manage the workbook Shapes in a Dictionary because
      - you're using the Shape ID as the Key and
      - the Key in a dictionary must be unique

    The best solution might be to combine the Worksheet CodeName property with the Shape.ID property as you populate the Dictionary. This should make the values unique. I propose CodeName rather than the Name property because that is less likely to be changed by the user and should also be unique.

    So the key value in the Dictionary could be something like: Sheet1_1, Sheet1_2, Sheet2_1, etc.

    I'm guessing, in any case, that it may be important to store the worksheet identification with the Shape ID so that you can refer back to that particular Shape at a later point...


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, January 9, 2013 9:18 AM
    Moderator

All replies

  • What error?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, January 8, 2013 1:03 PM
    Moderator
  • I created a dictionary, the shape id is the key and its alt attribute is the value, so the error appeared
    Wednesday, January 9, 2013 3:10 AM
  • I want to know that the situation appearing two shape id in common is normal or not
    Wednesday, January 9, 2013 3:13 AM
  • Hi IT漫步者,

    Thanks for posting in the MSDN Forum.

    I would recommend you provide detailed scenario to reproduce your issue. As far as you mentioned that there exists duplicate shareid in you spreadsheet document. Would you please tell me whether you can open it? And whether the document is generated via your code. Would you please share your code if you generate the document via your program for further research.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 9, 2013 5:26 AM
    Moderator
  • The amount of information you provide is still very small. I suspect we're dealing with the language barrier, to a certain extent... Let me try repeating back what I understand your problem to be and you confirm or correct it:

    • You have an Excel workbook that you're using Open XML SDK to analyze.
    • This workbook has multiple worksheets, and more than one of the worksheets has Shape objects on the surface.
    • Excel starts the numbering for the Shape ID value on each sheet with 1 (one), so it's possible that more than one Shape in the workbook has the same Shape ID
    • This is causing problems when you try to manage the workbook Shapes in a Dictionary because
      - you're using the Shape ID as the Key and
      - the Key in a dictionary must be unique

    The best solution might be to combine the Worksheet CodeName property with the Shape.ID property as you populate the Dictionary. This should make the values unique. I propose CodeName rather than the Name property because that is less likely to be changed by the user and should also be unique.

    So the key value in the Dictionary could be something like: Sheet1_1, Sheet1_2, Sheet2_1, etc.

    I'm guessing, in any case, that it may be important to store the worksheet identification with the Shape ID so that you can refer back to that particular Shape at a later point...


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, January 9, 2013 9:18 AM
    Moderator