Home > other >  The Unity of using NPOI operation Word document
The Unity of using NPOI operation Word document

Time:09-18

Old man, recently need to through the Unity operation Word file, but using Com component is always an error, and then said later in a post to see Unity doesn't support Com components (I don't have the validation), hence to borrow third-party libraries to operation directly,
Then after query found Docx and NPOI the two is more outstanding, but I'm making the above download, emmmmmmm, Docx not too will use, the code is all wrong, also can not find the reason,,, deduced NPOI Net20 version but in practice there are many mistakes,
OfficeManager script:
 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Using NPOI. XWPF. UserModel;
Using System. IO;

Public class OfficeManager
{
# region Instance
Private static OfficeManager m_instance;
Public static OfficeManager Instance
{
The get
{
If (m_instance==null)
{
M_instance=new OfficeManager ();
}
Return m_instance;
}
}
# endregion

///
///to create Word documents
///

Public void CreateWord ()
{
FileStream sw=File. The Create (" d: \ \ blank docx ");
Sw. Position=0;
XWPFDocument doc=new XWPFDocument (sw);//error
Doc. CreateParagraph ();
}
}


The Test script (mount) in the scene:

 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Public class Test: MonoBehaviour {

//Use this for initialization
Void the Start () {
OfficeManager. Instance. CreateWord ();
}

//Update is called once per frame
Void the Update () {

}
}


Error:
ZipException: EOF the header in
ICSharpCode.SharpZipLib.Zip.Com pression. Streams. InflaterInputBuffer. ReadLeByte ()
ICSharpCode.SharpZipLib.Zip.Com pression. Streams. InflaterInputBuffer. ReadLeShort ()
ICSharpCode.SharpZipLib.Zip.Com pression. Streams. InflaterInputBuffer. ReadLeInt ()
ICSharpCode. SharpZipLib. Zip. ZipInputStream. GetNextEntry ()
(wrapper remoting invoke - with - check) ICSharpCode. SharpZipLib. Zip. ZipInputStream: GetNextEntry ()
NPOI. OpenXml4Net. Util. ZipInputStreamZipEntrySource.. Ctor (ICSharpCode SharpZipLib. Zip. ZipInputStream inp)
NPOI. OpenXml4Net. OPC. ZipPackage.. Ctor (System. IO Stream filestream, PackageAccess access)
NPOI. OpenXml4Net. OPC. OPCPackage. Open (System. IO. Stream in1)
NPOI. Util. PackageHelper. Open (System. IO. Stream is1)
NPOI. XWPF. UserModel. XWPFDocument.. Ctor (System. IO Stream is1)
OfficeManager. CreateWord () (at Assets/Scripts/Manager/OfficeManager cs: 31)
Test. The Start () (9) at Assets/Test. Cs:

CodePudding user response:

The top once,,,

CodePudding user response:

Find ICSharpCode. SharpZipLib this library
Take a look at this and your corresponding library version

CodePudding user response:

The.net framework for framework for more than 4, https://download.csdn.net/download/qq_41001564/10754674 file into the Plugins
  • Related