我使用VS2015(使用.NET 2.0选项)构建了最新的NPOI代码(https://github.com/tonyqus/npoi),我可以运行VS2015内置的C#程序来创建和操作Excel工作簿。我想让Unity C#脚本使用NPOI库,但是当我尝试使用以下行创建工作簿时
IWorkbook workbook = new XSSFWorkbook();
我收到一个InvalidOperationException,其详细信息在本文末尾。我不熟悉NPOI代码,所以我真的不确定这里会发生什么。导致此错误的原因是什么?
这里出现了错误,我用例外的方式加粗了部分,但是如果它很重要,请留在堆栈信息中。对不起,如果它有点矫枉过正。
InvalidOperationException:类型NPOI.OpenXmlFormats.ItemChoiceType缺少枚举值' vstream' for element' vstream from 命名空间 ' 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成员, 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:反映字段'项目'
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:出现错误反映类型' 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类型,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成员, 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:反映字段属性的错误'。
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:出现错误反映类型' 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类型,System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) System.Xml.Serialization.XmlSerializer..ctor(System.Type类型, System.Xml.Serialization.XmlAttributeOverrides覆盖, System.Type [] extraTypes,System.Xml.Serialization.XmlRootAttribute root,System.String defaultNamespace) System.Xml.Serialization.XmlSerializer..ctor(System.Type类型) NPOI.OpenXmlFormats.CustomPropertiesDocument..cctor()
Rethrow as TypeInitializationException:类型初始值设定项引发异常 NPOI.OpenXmlFormats.CustomPropertiesDocument
NPOI.POIXMLProperties..cctor()
Rethrow as TypeInitializationException:NPOI.POIXMLProperties的类型初始化程序抛出异常
NPOI.POIXMLDocument.GetProperties()
将Lethrow改为POIXMLException
NPOI.POIXMLDocument.GetProperties() NPOI.XSSF.UserModel.XSSFWorkbook.OnWorkbookCreate() NPOI.XSSF.UserModel.XSSFWorkbook..ctor()TestExcel.Start()(at 资产/ TestExcel.cs:10)