Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sun Mar 24, 2024 11:14 am

Spire.Xls version:14.2.2
Python 3.11.8

Hello, I'm trying to use Python Spire.Xls to convert EXCEL to PDF on MACOS. I ran your demo code ToPDF.py in your Demos/07_Conversion
The result is showing

Traceback (most recent call last):
File "/Users/sebastian/Documents/spire.xls.python_14.2.2/Demos/07_Conversion/ToPDF.py", line 9, in <module>
workbook = Workbook()
^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/plum/function.py", line 642, in __call__
return self.f(self.instance, *args, **kw_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/plum/function.py", line 592, in __call__
return _convert(method(*args, **kw_args), return_type)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/spire/xls/Workbook.py", line 18, in __init__
intPtr = CallCFunction(GetDllLibXls().Workbook_CreateWorkbook)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/spire/xls/common/__init__.py", line 109, in CallCFunction
raise SpireException(info)
spire.xls.common.SpireException: TypeInitialization_Type_NoTypeAvailable: at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x160
at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x14
at Spire.Xls.Core.Spreadsheet.XlsWorksheet.InitializeCollections() + 0x2a4
at Spire.Xls.Core.Spreadsheet.XlsWorksheet..ctor(Object) + 0x74
at Spire.Xls.Core.Spreadsheet.Collections.XlsWorksheetsCollection.Add(String) + 0x70
at Spire.Xls.Core.Spreadsheet.XlsWorkbook.spra(Int32) + 0x400
at Spire.Xls.Workbook..ctor() + 0x58
at Spire.Xls.AOT.NLWorkbook.CreateWorkbook(IntPtr) + 0x40
Exception ignored in: <function Workbook.__del__ at 0x1067b5d00>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/spire/xls/Workbook.py", line 23, in __del__
CallCFunction(GetDllLibXls().Workbook_Dispose, self.Ptr)
^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/spire/xls/common/SpireObject.py", line 27, in Ptr
return self._ptr
^^^^^^^^^
AttributeError: 'Workbook' object has no attribute '_ptr'

Segfaultl
 
Posts: 1
Joined: Sun Mar 24, 2024 10:39 am

Mon Mar 25, 2024 7:53 am

Hello,

Thanks for your inquiry.
Kindly note that Spire.Xls for python relies on the SkiaSharp graphics library, please download libSkiaSharp.dylib first, then copy it to the root directory of your project and try again. If you have any other questions, please feel free to write back.

Sincerely,
William
E-iceblue support team
User avatar

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

Return to Spire.XLS