OfficeDev / Open-Xml-PowerTools

MIT License
693 stars 26 forks source link

Exception during conversion of html table to docx #198

Closed AlirezaAhmadiRad closed 5 years ago

AlirezaAhmadiRad commented 6 years ago

Hello I have this html file. This is code for converting it to docx:

XElement X = XElement.Parse(HT.HTML); HtmlToWmlConverterSettings S = HtmlToWmlConverter.GetDefaultSettings(); WmlDocument D = HtmlToWmlConverter.ConvertHtmlToWml("", "", "", X, S); sources.Add(new Source(D, true));

Then I receive exception of "Object reference not set to an instance of an object." at this address:

at OpenXmlPowerTools.HtmlToWml.HtmlToWmlConverterCore.GetTableGrid(XElement element, HtmlToWmlConverterSettings settings)
at OpenXmlPowerTools.HtmlToWml.HtmlToWmlConverterCore.Transform(XNode node, HtmlToWmlConverterSettings settings, WordprocessingDocument wDoc, NextExpected nextExpected, Boolean preserveWhiteSpace)
at OpenXmlPowerTools.HtmlToWml.HtmlToWmlConverterCore.<>c__DisplayClass20_0.b__6(XNode n)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content) at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content) at OpenXmlPowerTools.HtmlToWml.HtmlToWmlConverterCore.UpdateMainDocumentPart(WordprocessingDocument wDoc, XElement html, HtmlToWmlConverterSettings settings) at OpenXmlPowerTools.HtmlToWml.HtmlToWmlConverterCore.ConvertHtmlToWml(String defaultCss, String authorCss, String userCss, XElement xhtml, HtmlToWmlConverterSettings settings, WmlDocument emptyDocument, String annotatedHtmlDumpFileName) at OpenXmlPowerTools.HtmlToWmlConverter.ConvertHtmlToWml(String defaultCss, String authorCss, String userCss, XElement xhtml, HtmlToWmlConverterSettings settings) at WebOS.Engine.V100.WebOSIO.GenerateWordReport(List1 Tables, Guid FileID, String FileName, ReportType FileType, Guid OwnerProgramID, RemoteLogin ID)

I'm using nuget version 4.5.3.2 Could you please help?

lpperras commented 6 years ago

Might be solved with PR #200.

tomjebo commented 5 years ago

Closing all issues as this repo is being archived and will no longer be maintained by Microsoft. The project is licensed for continued use and development by forking to your own repo.