Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Jun 27, 2024 10:54 pm

I am having trouble when adding a table (or performing some formatting options) to word documents. The code was originally developed on Windows (11), and works correctly. When I try to run the same code, it results in a variety of errors, all of which start with "ffi_prep_cif_var failed". They generally seem to happen when creating tables or performing formatting operations.

I've created a MWE, which can be found at github: /EricRobertCampbell/spire-doc-failure-mwe.

The code is
Code: Select all
#!/usr/bin/env python3

from spire.doc import *
from spire.doc.common import *

def main():
    doc = Document()

    section = doc.AddSection()

    table = Table(doc, True)

    section.Tables.Add(table)

    doc.SaveToFile("table.docx", FileFormat.Docx2019)
    doc.Close()
    doc.Dispose()

if __name__ == "__main__":
    main()


which is taken almost vebatim from the tutorial here: (this site) /Tutorials/Python/Spire.Doc-for-Python/Program-Guide/Table/Python-Create-Tables-in-a-Word-Document.html.

The error in this case is
Code: Select all
Traceback (most recent call last):
  File "/home/eric/documents/spire-doc-failure-poc/./generate.py", line 20, in <module>
    main()
  File "/home/eric/documents/spire-doc-failure-poc/./generate.py", line 11, in main
    table = Table(doc, True)
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/plum/function.py", line 642, in __call__
    return self.f(self.instance, *args, **kw_args)
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/plum/function.py", line 592, in __call__
    return _convert(method(*args, **kw_args), return_type)
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/spire/doc/Table.py", line 37, in __init__
    intPtr = CallCFunction(GetDllLibDoc().Table_CreateTableDS,intPdoc,showBorder)
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/spire/doc/common/__init__.py", line 105, in CallCFunction
    result = func(*args, **kwargs)
RuntimeError: ffi_prep_cif_var failed
Exception ignored in: <function SpireObject.__del__ at 0x7f1d93c1dee0>
Traceback (most recent call last):
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/spire/doc/common/SpireObject.py", line 31, in __del__
    CallCFunction(dlllib.Spire_FreeHandle,self.Ptr)
  File "/home/eric/documents/spire-doc-failure-poc/venv/lib/python3.9/site-packages/spire/doc/common/SpireObject.py", line 27, in Ptr
    return self._ptr
AttributeError: 'Table' object has no attribute '_ptr'


We are also using Spire.Xls on the same project, and I can use that just fine.

My environment:
Windows: 11 Home, version 10.0.22631 Build 22631
Python: 3.9.16
Spire.Doc 12.4.0
WSL Version 2.2.4.0
WSL Kernel Version 5.15.153.1-2 (Ubuntu)

Sorry for the lack of proper URLs; apparently I'm not allowed to post them.

Please let me know if there's any additional information I can provide. We would very much like to use this, but obviously the inability to create tables or change formatting options is a deal breaker!

ericcampbell
 
Posts: 10
Joined: Thu Jun 27, 2024 10:39 pm

Fri Jun 28, 2024 3:33 am

Hello,

Thanks for your inquiry.
Yes, I have reproduced the issue you mentioned in the Ubuntu system. I have logger it to our tracking system with ticket SPIREDOC-10645 and our deve will further investigate and fix it. Once there is any progress, I will inform you as soon as possible.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Tue Jul 02, 2024 2:24 pm

That;s great, thank you! We look forward to hearing from you with a fix.

ericcampbell
 
Posts: 10
Joined: Thu Jun 27, 2024 10:39 pm

Wed Jul 17, 2024 1:28 pm

For anyone else looking for this: the recent 12.7.1 update seems to have fixed it.

ericcampbell
 
Posts: 10
Joined: Thu Jun 27, 2024 10:39 pm

Return to Spire.Doc