Giter Site home page Giter Site logo

mikeebowen / ooxml-validator-vscode Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 2.0 44.65 MB

A VS Code extension for validating Office Open XML files

Home Page: https://marketplace.visualstudio.com/items?itemName=mikeebowen.ooxml-validator-vscode

License: MIT License

TypeScript 97.48% JavaScript 2.52%
ooxml validation vscode-extension validator office-open-xml

ooxml-validator-vscode's Introduction

VS Marketplace Unit Tests Coverage Status Project License

OOXML Validator VS Code Extension

The OOXML Validator validates Office Open XML files (.docx, .docm, .dotm, .dotx, .pptx, .pptm, .potm, .potx, .ppam, .ppsm, .ppsx, .xlsx, .xlsm, .xltm, .xltx, or .xlam) and displays the validation errors found in the xml parts in VSCode and creates an optional CSV or JSON log file of the validation errors.

Features

  • Validates Office Open XML files against Office Perpetual 2007, 2010, 2013, 2016, 2019, 2021, or Microsoft 365 Subscription Defaults to Microsoft 365 Subscription
  • Creates optional CSV or JSON log file of the errors.

Usage

To validate an OOXML file, right click on the file to validate and select "Validate OOXML". This displays the validation errors in the VS Code window. If ooxml.outPutFilePath is set, a log of the validation errors is created (defaults to .csv).

Demonstration of OOXML Viewer VS Code Extension

* Using Excel Viewer to view the .csv file.

Extension Settings

This extension contributes the following settings:

  • ooxml.fileFormatVersion: Number that specifies the version of Office to use to validate OOXML files. Must be in [2007, 2010, 2013, 2016, 2019, 2021, 365]. If no value is set or the value is not valid, defaults to 365. For the Office version 365 refers to the subscription product (Microsoft 365), while the other versions refer the perpetual versions for a given year.
  • ooxml.outPutFilePath: String that specifies the absolute file path to write the output of the validator. If the file name does not end in ".json" or ".csv", ".csv" will be appended to the filename and saved as a .csv file. Path MUST be absolute. If no value is set, no log file will be saved.
  • ooxml.overwriteLogFile: If true, the new log file will overwrite previous log file of the same name if it exists. If false, a unique timestamp is added to the filename. Default is false.
  • ooxml.dotNetPath: The absolute path to the .Net Runtime. Path MUST be absolute. If not set, the extension will download the latest dotnet runtime.

The path to the dotnet runtime executable will be similar to "C:\\Program Files\\dotnet\\dotnet.exe" for Windows and "/usr/local/share/dotnet/dotnet" for macos. For more information on finding the path to the dotnet executable, this Stack Overflow post explains it for Windows and this post explains how to find it on macos.

Release Notes

Please see the Changelog


Logo created with LogoMakr.com

ooxml-validator-vscode's People

Contributors

dependabot[bot] avatar mikeebowen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ooxml-validator-vscode's Issues

Can't open file

I know that this isn't caused by the validator but my .NET experience is extremely limited. I work on a Python library for OOXML and am getting this error when trying to validate a file I've created:

Failed to run OOXML Validator: Unhandled exception. System.ArgumentException: Part URI cannot end with a forward slash.
   at System.IO.Packaging.PackUriHelper.ValidatePartUri(Uri partUri)
   at System.IO.Packaging.PackUriHelper.IsRelationshipPartUri(Uri partUri)
   at System.IO.Packaging.InternalRelationshipCollection.Add(Uri targetUri, TargetMode targetMode, String relationshipType, String id, Boolean parsing)
   at System.IO.Packaging.InternalRelationshipCollection.ProcessRelationshipAttributes(XmlCompatibilityReader reader)
   at System.IO.Packaging.InternalRelationshipCollection.ParseRelationshipPart(PackagePart part)
   at System.IO.Packaging.InternalRelationshipCollection..ctor(Package package, PackagePart part)
   at System.IO.Packaging.InternalRelationshipCollection..ctor(PackagePart part)
   at System.IO.Packaging.PackagePart.EnsureRelationships()
   at System.IO.Packaging.PackagePart.GetRelationshipsHelper(String filterString)
   at System.IO.Packaging.PackagePart.GetRelationships()
   at DocumentFormat.OpenXml.Packaging.PackagePartRelationshipPropertyCollection..ctor(PackagePart packagePart)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, RelationshipCollection relationshipCollection, Dictionary`2 loadedParts)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load(Package _package)
   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage..ctor(PackageLoader& loader, OpenSettings settings)
   at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument..ctor(PackageLoader& loader, OpenSettings settings)
   at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)
   at DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(String path, Boolean isEditable)
   at OOXMLValidatorCLI.Classes.Document.OpenSpreadsheetDocument(String filePath) in C:\source\OOXMLValidator\OOXMLValidatorCLI\Classes\Document.cs:line 23
   at OOXMLValidatorCLI.Classes.FunctionUtils.GetDocument(String filePath) in C:\source\OOXMLValidator\OOXMLValidatorCLI\Classes\FunctionUtils.cs:line 53
   at OOXMLValidatorCLI.Classes.Validate.OOXML(String filePath, Nullable`1 format) in C:\source\OOXMLValidator\OOXMLValidatorCLI\Classes\Validate.cs:line 22
   at OOXMLValidatorCLI.Program.Main(String[] args) in C:\source\OOXMLValidator\OOXMLValidatorCLI\Program.cs:line 32

I guess this is coming from a Relationship but I can't find any internal relations that end with a "/" (there are some external URLs that do). Is it possible to add to the exception the actual element causing problems? Or is there something else I can do?

Strict Validation

For context see the discussion
#13

Latest reply from @mikeebowen

Hi @Asbjoedt, that PR was merged in the SDK, so we are able to determine strict vs transitional. Most of the changes will actually be in the OOXML Validator. This isn't a validation error, so I will have to extend the validator and get the information manually and add it in. I will work to get this in when I can. Please create a feature request on the issues page to help track this. Thanks!

Our situation
We have a big interest in seeing this feature implemented. Reach out if you need help other than coding.

Error Validating Word 2007 File

Trying to validate a docx file. Changing the File Format Version appears to work for all values except 2007. When I try to use 2007, I get a pop-up error "Unexpected token U in JSON at position 0". Validation passes for all other versions.

Screenshot 2022-11-29 102528

Allow validation of OOXML macro-enabled and add-in files

Hi

Could you allow the validator to process files with the following extensions:

  • .docm, .dotm, .dotx (Word macro-enabled document, macro-enabled template, macroless template)
  • .xlsm, .xltm, .xltx, .xlam (Same for excel, plus add-in)
  • .pptm, .potm, .potx, .ppam, .ppsm, .ppsx (Same for PowerPoint, plus macro-enabled and macroless show files)

These are all OOXML files, so the validator should work just fine on them.

Trouble running the ooxml-validator-vscode

Screenshot 2023-10-31 at 5 16 23 PM Whenever i run validate ooxml i see this error saying: `Failed to run OOXML Validator. The error was: It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '6.0.0' was not found. - The following frameworks were found: 3.1.32 at [/Users/kushalpatilms/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/3.1.32~arm64/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

I saw this same issue was reported and the solution was to add "ooxml.dotNetPath" in settings which i did as shown below:

Screenshot 2023-10-31 at 5 18 54 PM

Im getting "undefined is not a valid json" as shown below:

Screenshot 2023-10-31 at 5 20 08 PM

I have tried it without quotes aswell but it doesnt seem to have any effect.
Thanks in advance.

Having difficulty using validator in VS Code

Hi Mike! Thank you for answering my issue posted to the wrong repo. I think I am getting closer, because I can now right click and see the Validate OOXML.

When I attempt to validate a DOCX, I get the error regarding Microsoft.NetCore.App version 6.0.0 not found. I have installed the .Net Core 3.1 runtime (https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-3.1.30-windows-x64-installer?cid=getdotnetcoreJ) as well as the .NET Install Tool for Extension Authors. But I still must be missing something. Do I need to install .Net 6.0 from https://dotnet.microsoft.com/en-us/download/dotnet ? Also, I am not sure which specific file to use for the absolute path in the extension's settings. Any pointers will be appreciated! Thanks

Commas in certain values fails validation

Hi 👋🏻 Wish I could be more helpful regarding this but a fresh Normal.dotm generated on a sv-SE localised system throws the following errors on validation.

I pasted the CSV of the logs below.

I managed to work around this issue by removing the commas from the fields in question.

I do not expect any fix, just wanted to let you know in case you are interested.

Id,Description,Namespaces,NamespacesDefinitions,XPath,PartUri,ErrorType
"""Sem_AttributeValueDataTypeDetailed""","""The attribute 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:val' has invalid value 'Konfidentiellt, Sidnr, Datum'. The Pattern constraint failed. The expected pattern is ^[^,]*$.""",{},"[
  ""xmlns:w=\""http://schemas.openxmlformats.org/wordprocessingml/2006/main\""""
]","""/w:glossaryDocument[1]/w:docParts[1]/w:docPart[51]/w:docPartPr[1]/w:name[1]""","""/word/glossary/document.xml""","""Schema"""
"""Sem_AttributeValueDataTypeDetailed""","""The attribute 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:val' has invalid value 'Författare, Sidnr, Datum'. The Pattern constraint failed. The expected pattern is ^[^,]*$.""",{},"[
  ""xmlns:w=\""http://schemas.openxmlformats.org/wordprocessingml/2006/main\""""
]","""/w:glossaryDocument[1]/w:docParts[1]/w:docPart[50]/w:docPartPr[1]/w:name[1]""","""/word/glossary/document.xml""","""Schema"""

This is the passage in glossary/Document.xml which causes the issue.

<w:docPartPr>
    <w:name w:val="Konfidentiellt, Sidnr, Datum" />
    <w:style w:val="Sidhuvud/sidfot" />
    <w:category>
        <w:name w:val="Allmänt" />
        <w:gallery w:val="autoTxt" />
    </w:category>
    <w:behaviors>
        <w:behavior w:val="content" />
    </w:behaviors>
    <w:guid w:val="[redacted]" />
</w:docPartPr>

Troubleshooting running

Hello Mike,

Looking forward using your Extension to validate some excel files. However I do not seem to get it to work.

Maybe you can point me in the right direction.

I am working on a Mac and am running Visual Studio Code 1.80.0.

I have installed the latest dotnet. dotnet --info tells me:
Microsoft.NETCore.App 7.0.0 [/usr/local/Cellar/dotnet/7.0.100/libexec/shared/Microsoft.NETCore.App]

This is then also the path I put in settings.json:

"ooxml.dotNetPath": "/usr/local/Cellar/dotnet/7.0.100/libexec/shared/Microsoft.NETCore.App",

When I try running the extension, I get the following error:

"undefined" is not a valid JSON

thanks for you response!

Regards,
Jeroen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.