Giter Site home page Giter Site logo

onizet / html2openxml Goto Github PK

View Code? Open in Web Editor NEW
297.0 17.0 106.0 1.58 MB

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments from SharePoint to Word.

License: MIT License

C# 100.00%
docx openxml openxml-sdk dotnet-core

html2openxml's Introduction

Latest version Download Counts MIT License

What is Html2OpenXml?

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments into Word.

This library supports both .Net Framework 4.6.2, .NET Standard 2.0 and .NET 8 which are all LTS.

Depends on DocumentFormat.OpenXml and AngleSharp.

See Also

Supported Html tags

Refer to w3schools’ tag list to see their meaning

  • a
  • h1-h6
  • abbr and acronym
  • b, i, u, s, del, ins, em, strike, strong
  • br and hr
  • img, figcaption
  • table, td, tr, th, tbody, thead, tfoot, caption and col
  • cite
  • div, span, time, font and p
  • pre
  • sub and sup
  • ul, ol and li
  • dd and dt
  • q, blockquote, dfn
  • article, aside, section are considered like div

Javascript (script), CSS style, meta, comments, buttons and input controls are ignored. Other tags are treated like div.

In v1 and v2, Javascript (script), CSS style, meta, comments and other not supported tags does not generate an error but are ignored.

Html Parser

In v3, the parsing of the Html relies on AngleSharp package, which follows the W3C specifications and actively supports Html5.

In v1 and v2, the parsing of the Html was done using a custom Regex-based enumerator and was more flexible, but leaving a complex code, hard to maintain.

How to implement or debug features

My reference bibles cover both OpenXml and HTML:

Open MS Word or Apple Pages and design your expected output. Save as a DOCX file, then rename as a ZIP. Extract the content and inspect those files: document.xml, numbering.xml (for list) and styles.xml.

Acknowledgements

Thank you to all contributors that share their bug fixes (in no particular order): scwebgroup, ddforge, daviderapicavoli, worstenbrood, jodybullen, BenBurns, OleK, scarhand, imagremlin, antgraf, mdeclercq, pauldbentley, xjpmauricio, jairoXXX, giorand, bostjanKlemenc, AaronLS, taishmanov. And thanks to David Podhola for the Nuget package.

Logo provided with the permission of Enhanced Labs Design Studio.

Support

This project is open source and I do my best to support it in my spare time. I'm always happy to receive Pull Request and grateful for the time you have taken If you have questions, don't hesitate to get in touch with me!

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.