System.TypeLoadException: Could not resolve type with token 01000080 from typeref (expected class 'ICSharpCode.SharpZipLib.Zip.UseZip64' in assembly 'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73')
at NPOI.OpenXml4Net.OPC.OPCPackage.Save (System.IO.Stream outputStream) [0x00006] in <99616821a9154f2ca86e81f2f10656d7>:0
at NPOI.POIXMLDocument.Write (System.IO.Stream stream) [0x00096] in:0
at WordCreat_Script.createParagraph (NPOI.XWPF.UserModel.ParagraphAlignment _alignment, System.Int32 _fontSize, System.String _color, System.String _content) [0x00044] in E:\Unity20221231\SqliteTest\Assets_VR_HBT_HR_Scripts\Create_WordDoc_Scripts\WordCreat_Script.cs:38
UnityEngine.Debug:LogError (object)
WordCreat_Script:createParagraph (NPOI.XWPF.UserModel.ParagraphAlignment,int,string,string) (at Assets/_VR_HBT_HR_Scripts/Create_WordDoc_Scripts/WordCreat_Script.cs:42)
WordCreat_Script:Start () (at Assets/_VR_HBT_HR_Scripts/Create_WordDoc_Scripts/WordCreat_Script.cs:17)
Unity 之 实现读取代码写进Word文档功能实现 -- 软著脚本生成工具_unity 读取word-CSDN博客
然后出现了报错显示
C#使用NPOI进行Excel导入时ICSharpCode.SharpZipLib版本冲突-CSDN博客
然后继续一些安装流程,安装完成后
"0.0.0.0-0.86.0.518" newVersion="0.86.0.518" />
下载后,将该文件夹拖入Unity的Plugins文件夹下。
若有冲突报错,删掉之前那个版本的
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using NPOI.XWPF.UserModel;
- using System.IO;
- using System;
- public class WordCreat_Script : MonoBehaviour
- {
- ///
- /// 文件路径
- ///
- private const string filePath = @"C:/Users/Administrator/Desktop";
-
- ///
- /// 文件名称
- ///
- private string fileName = "david.docx";
-
- private string path;
-
- ///
- /// word文档
- ///
- private XWPFDocument doc = new XWPFDocument();
-
- private void Start()
- {
- //缝合路径
- path = Path.Combine(filePath, fileName);
- StartCoroutine(a());
- }
- IEnumerator a()
- {
- yield return new WaitForSeconds(1);
- CreateParagraph(ParagraphAlignment.CENTER, 20, "000000", "VR心理辅助治疗系统体验报告");
- }
- ///
- /// 创建段落
- ///
- /// 对齐方式
- /// 字体大小
- /// 字体颜色(16进制)
- /// 内容
- private void CreateParagraph(ParagraphAlignment _alignment, int _fontSize,
- string _color, string _content)
- {
- XWPFParagraph paragraph = doc.CreateParagraph();
- paragraph.Alignment = _alignment;
- XWPFRun run = paragraph.CreateRun();
- run.FontSize = _fontSize;
- run.SetColor(_color);
- run.FontFamily = "宋体";
- run.SetText(_content);
- FileStream fs = new FileStream(path, FileMode.Create);
- doc.Write(fs);
- fs.Close();
- fs.Dispose();
- Debug.Log("写入成功");
- }
-
- }