OpenXML spreadsheet created in .NET won't open in iPad

后端 未结 5 2029
梦毁少年i
梦毁少年i 2020-12-16 05:59

I am trying to generate a spreadsheet in .NET which will be opened by my manager on his iPad when he\'s out of the office.

The spreadsheet opens fine on a Windows PC

5条回答
  •  时光取名叫无心
    2020-12-16 06:37

    You could try to validate OpenXML spreadsheet once it's created:

    using System;
    using System.Collections.Generic;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Validation;
    
    using (OpenXmlPackage document = SpreadsheetDocument.Open(spreadsheetPathToValidate, false))
    {
        var validator = new OpenXmlValidator();
        IEnumerable errors = validator.Validate(document);
        foreach (ValidationErrorInfo info in errors)
        {
            try
            {
                Console.WriteLine("Validation information: {0} {1} in {2} part (path {3}): {4}",
                            info.ErrorType,
                            info.Node.GetType().Name,
                            info.Part.Uri,
                            info.Path.XPath,
                            info.Description);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Validation failed: {0}", ex);
            }
        }
    }
    

    Hope that helps,

提交回复
热议问题