Send to Excel - Error

JedroxJedrox Member Posts: 2
edited 2022-02-03 in NAV Three Tier
Hello, greetings, my name is Jhonny.
If I press send to excel button in my client version of nav 2015, my session is closed.
I've been checking the event viewer and found this:

Message: '', hexadecimal value 0x02, is an invalid character
StackTrace:
en System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(Int32 ch, Byte* pDst, Boolean entitize)
en System.Xml.XmlUtf8RawTextWriter.WriteElementTextBlock(Char* pSrc, Char* pSrcEnd)
en System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
en System.Xml.XmlWellFormedWriter.WriteString(String text)
en DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
en DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
en DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
en DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
en DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
en DocumentFormat.OpenXml.OpenXmlPartWriter.WriteElement(OpenXmlElement elementObject)
en Microsoft.Dynamics.Nav.Runtime.Office.OfficeExcelListRender.ReplaceDataSheet(Stream dataStream, WorksheetWriter worksheetWriter, Func`1 valueLists)
en Microsoft.Dynamics.Nav.Runtime.Office.OfficeExcelListRender.WriteDataStream(Stream dataStream)
en Microsoft.Dynamics.Nav.Runtime.Office.OfficeExcelListRender.GenerateExcelDocument(String filename)
en Microsoft.Dynamics.Nav.Runtime.NavForm.SaveAsExcel(DataError errorLevel, Int32 languageId, String fileName)
en Microsoft.Dynamics.Nav.Service.NSService.SendDataToDocument(NavRecordState recordState, OfficeDocumentType documentType)
en SyncInvokeSendDataToDocument(Object , Object[] , Object[] )
en System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
en Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs)
Source: System.Xml

The weird thing is that if I do this inside the server, this error doesn't occur.
Please help.

Best Answer

  • ShaiHuludShaiHulud Member Posts: 228
    Answer ✓
    One possibility is that the data you're trying to export has some invalid characters, such as newlines and similar. It happens quite often when, for example, users copy Customer/Vendor address from their website, or Excel and accidentally copy in an invisible newline character. NAV client doesn't show them, but they are in the actual data. So you'd need to investigate the data that causes this error for any invalid characters.

    As for why it works on the server, my best guess would be that different versions of some system DLLs are the culprit

Answers

  • ShaiHuludShaiHulud Member Posts: 228
    Answer ✓
    One possibility is that the data you're trying to export has some invalid characters, such as newlines and similar. It happens quite often when, for example, users copy Customer/Vendor address from their website, or Excel and accidentally copy in an invisible newline character. NAV client doesn't show them, but they are in the actual data. So you'd need to investigate the data that causes this error for any invalid characters.

    As for why it works on the server, my best guess would be that different versions of some system DLLs are the culprit
  • JedroxJedrox Member Posts: 2
    Thanks for your reply, that seems to be the reason.
    So far I have found a couple of these in the database.
    Do you know of any way to remove these characters from the database?
    My idea is to use "DELCHR" 2 times in nav, the first to save the special characters and the second to delete these same characters.
  • ShaiHuludShaiHulud Member Posts: 228
    As long as you know the illegal characters (or their ASCII code), you shouldn't need to do it twice. Once should be enough, f.x.:
    Customer.GET(CustomerCode); //Or filter and loop through
    Customer.Address := DELCHR(IllegalCharVar, '=', Customer.Address);
    Customer.Modify(false);
    

    If you don't know exactly in which field the characters are, you should look doing this in SQL, as it would probably be significantly faster than for C/AL code to loop through each record's each text/code field looking for the characters.
  • krikikriki Member, Moderator Posts: 9,094
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.