Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Created Unassigned: InvalidOperationException when writing xlsx file through .dll [13911]

$
0
0
When using a .dll to write an .xlsx file, I am getting the error below. The same code works when using a basic WinForms application:

InvalidOperationException: Type NPOI.OpenXmlFormats.ItemChoiceType is missing enumeration value 'r4' for element 'r4 from namespace 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'.
System.Xml.Serialization.XmlReflectionImporter.ImportElementInfo (System.Type cls, System.String defaultName, System.String defaultNamespace, System.Type defaultType, System.Xml.Serialization.XmlTypeMapMemberElement member, System.Xml.Serialization.XmlAttributes atts)
System.Xml.Serialization.XmlReflectionImporter.CreateMapMember (System.Type declaringType, System.Xml.Serialization.XmlReflectionMember rmember, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
Rethrow as InvalidOperationException: There was an error reflecting field 'Item'.
System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
Rethrow as InvalidOperationException: There was an error reflecting type 'NPOI.OpenXmlFormats.CT_Property'.
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportElementInfo (System.Type cls, System.String defaultName, System.String defaultNamespace, System.Type defaultType, System.Xml.Serialization.XmlTypeMapMemberElement member, System.Xml.Serialization.XmlAttributes atts)
System.Xml.Serialization.XmlReflectionImporter.CreateMapMember (System.Type declaringType, System.Xml.Serialization.XmlReflectionMember rmember, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
Rethrow as InvalidOperationException: There was an error reflecting field 'property'.
System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
Rethrow as InvalidOperationException: There was an error reflecting type 'NPOI.OpenXmlFormats.CT_CustomProperties'.
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace)
System.Xml.Serialization.XmlSerializer..ctor (System.Type type)
NPOI.OpenXmlFormats.CustomPropertiesDocument..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for NPOI.OpenXmlFormats.CustomPropertiesDocument
NPOI.POIXMLProperties..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for NPOI.POIXMLProperties
NPOI.POIXMLDocument.GetProperties ()
Rethrow as POIXMLException
NPOI.POIXMLDocument.GetProperties ()
NPOI.XSSF.UserModel.XSSFWorkbook.OnWorkbookCreate ()
NPOI.XSSF.UserModel.XSSFWorkbook..ctor ()

The basic code being used to write the file is:
```
if (!File.Exists(fullPath))
{
var wb = new XSSFWorkbook();

// create sheet
var sh = (XSSFSheet)wb.CreateSheet("Sheet1");
// 3 rows, 2 columns
for (int i = 0; i < 3; i++)
{
var r = sh.CreateRow(i);
for (int j = 0; j < 2; j++)
{
r.CreateCell(j);
}
}

using (var fs = new FileStream(fullPath, FileMode.Create, FileAccess.Write))
{
wb.Write(fs);
}
}
```

Thank you!

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>