-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CT_Text.Write throws null exception #180
Comments
I have the same problem. Could you solve it? |
Please upload your word template to help reproduce the issue |
Original Good.docx And here is how I save it: Dim out As New FileStream(FileNameSaved, FileMode.Create, FileAccess.Write) |
And this are the functions that I create to write in a word document (most of them to write in tables), maybe this can help other people |
@tonyqus, I found the error. In my function WriteCell the text was nothing, so when I call SetText(text) did not through an exception but yes when I try to save it, so that was the problem. I update my function in the document attached. |
If valueField is null do nothing fix #180
doc.Write(outFile);
{System.NullReferenceException: Object reference not set to an instance of an object.
at NPOI.OpenXml4Net.Util.XmlHelper.EncodeXml(String xml)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Text.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_R.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_P.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Tc.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Row.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Tbl.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Body.Write(StreamWriter sw, String nodeName)
at NPOI.OpenXmlFormats.Wordprocessing.CT_Document.Write(StreamWriter sw)
at NPOI.OpenXmlFormats.Wordprocessing.DocumentDocument.Save(Stream stream)
at NPOI.XWPF.UserModel.XWPFDocument.Commit()
at NPOI.POIXMLDocumentPart.OnSave(List`1 alreadySaved)
at NPOI.POIXMLDocument.Write(Stream stream)
The text was updated successfully, but these errors were encountered: