我如何在Unity中使用NPOI,InvalidOperationException错误

时间:2017-05-11 07:19:26

标签: c# unity3d npoi

我想在Unity中通过NPOI导出.docx文件。但是它给了我一个错误。相同的代码可以在FormsApp中使用,但它在Unity中不起作用。

FileStream stream = File.Open(sPath, FileMode.Open, FileAccess.ReadWrite);
XWPFDocument doc = new XWPFDocument(stream);
stream.Close();
FileStream newStream = new FileStream(tPath, FileMode.Create);
doc.Write(newStream); // ERROR LINE
newStream.Close();
  

InvalidOperationException:输入NPOI.OpenXmlFormats.ItemChoiceType是   缺少枚举值' vstream' for element' vstream from   命名空间   ' http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes&#39 ;.   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()将Rethrow改为POIXMLException   NPOI.POIXMLDocument.GetProperties()NPOI.POIXMLDocument.Write   (System.IO.Stream流)UiControl.OutWord()(at   Assets / Script / UiControl.cs:312)UiControl.Grp1Btn2Click()(at   Assets / Script / UiControl.cs:288)EventDelegate.Execute()(at   资产/ NGUI /脚本/内部/ EventDelegate.cs:476)   EventDelegate.Execute(System.Collections.Generic.List`1 list)(at   Assets / NGUI / Scripts / Internal / EventDelegate.cs:644)UIButton.OnClick()   (在Assets / NGUI / Scripts / Interaction / UIButton.cs:252)   UnityEngine.GameObject:SendMessage(String,Object,SendMessageOptions)   UICamera:通知(GameObject,String,Object)(at   资产/ NGUI /脚本/ UI / UICamera.cs:1469)   UICamera:ProcessRelease(布尔值,单个)(at   资产/ NGUI /脚本/ UI / UICamera.cs:2325)   UICamera:ProcessTouch(布尔值,布尔值)(at   资产/ NGUI /脚本/ UI / UICamera.cs:2375)UICamera:ProcessMouse()(at   Assets / NGUI / Scripts / UI / UICamera.cs:1830)UICamera:ProcessTouches()(at   Assets / NGUI / Scripts / UI / UICamera.cs:1943)UICamera:Update()(at   资产/ NGUI /脚本/ UI / UICamera.cs:1631)

0 个答案:

没有答案