none
Could I validate SpreadSheetML parts separately using Open XML SDK? RRS feed

  • Question

  • Could I validate the SpreadSheetML parts separately using Open XML SDK?

    For example, validate the spreadsheets one by one or shared strings table?

    The idea is to economize memory and to make large documents validation available.

    Friday, October 14, 2011 8:07 AM

All replies

  • Hi mynameismasel,

    Thanks for posting in the MSDN Forum.

    You can validate the SpreadSheetML parts separately. I means the you can validate it based on every OpenXml Parts. Such as WorkbookPart, WorksheetPart, SharestringPart etc.

    Have a good day,

    Tom 


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 17, 2011 10:26 AM
    Moderator
  • Hi mynameismasel,

    Thanks for posting in the MSDN Forum.

    You can validate the SpreadSheetML parts separately. I means the you can validate it based on every OpenXml Parts. Such as WorkbookPart, WorksheetPart, SharestringPart etc.

    Have a good day,

    Tom 


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Thank you for the answer, Tom.

    I tried it on my large documents. I see no difference in the behaviour (OutOfMemoryException), cause my documents are very large. But I`ll mark the fact of separate Parts validation possibility.

    Monday, October 17, 2011 10:45 AM
  • Hi mynameismasel,

     

    I think the root result is based on the Xml’s parse way. In theory, Xml file’s content must be loaded into memory before parse. And In Excel OpenXml format file there have several part which will have big content in it. Especially worksheet part, workbook part and shared strings part will have big content in it. If you validate this part you will still get “Out of Memory” exception. And if you want to validate the node parts below these parts the application must load them first.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, October 18, 2011 4:56 AM
    Moderator
  • Hi mynameismasel,

     

    I think the root result is based on the Xml’s parse way. In theory, Xml file’s content must be loaded into memory before parse. And In Excel OpenXml format file there have several part which will have big content in it. Especially worksheet part, workbook part and shared strings part will have big content in it. If you validate this part you will still get “Out of Memory” exception. And if you want to validate the node parts below these parts the application must load them first.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    I wonder, could I validate, for example, just rows and cells from the spreadsheet (markup, attributes and values)?

    Or just the strings from the shared strings tables?

    I don`t know how to do it. For example, if I use the code like

     while (reader.Read()) {

                        if (reader.ElementType == typeof(Row)) {
                            
                            foreach (ValidationErrorInfo error in validator.Validate(reader.LoadCurrentElement()))
                            {
                                count++;
                                Console.WriteLine("Error " + count);
                                Console.WriteLine("Description: " + error.Description);
                                Console.WriteLine("Path: " + error.Path.XPath);
                                Console.WriteLine("Part: " + error.Part.Uri);
                                Console.WriteLine("-------------------------------------------");
                            }
                           
                            //validator.Validate(reader.LoadCurrentElement());
                           
                        }

                    }

    what row parameters would it validate?

    And as for cell valiadtion, I`m totally discouraged. For example, does validating Cell mean validating Cellvalue also? And so on...

    p.s.

    Sorry for missing code markup. My Internet Explorer browser is broken and I have currently no availability of PC restart.

    Thursday, October 20, 2011 7:26 AM