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.

Tue Aug 29, 2023 7:36 pm

Good Afternoon,

Back story, I am updating a docker container, lambda function, to handle convert an xls/xlsx and all of its sheets to pdf. Here is what os is running in the container:
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="amazon linux.com/"
VARIANT_ID="202308151228-2.0.1114.0"


The docker file is very simple.
FROM public .ecr .aws/lambda/python:latest

COPY requirements.txt .
RUN python -m pip install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"

COPY app.py ${LAMBDA_TASK_ROOT}

CMD [ "app.lambda_handler" ]


Here is the basic requirements.txt
boxsdk[jwt]
urllib3<2

Spire.XLS-for-Python
plum-dispatch==1.7.4


Within this container we have been evaluating open source conversion software, but the quality of these are poor. The basic python below is what is being tested.
Code: Select all
def convert_sheets_to_pdf_SPIRE(input_file, output_file):
    workbook = Workbook()
    workbook.LoadFromFile(input_file)

    for sheet in workbook.Worksheets:
        pageSetup = sheet.PageSetup
       
        pageSetup.TopMargin = 0.3
        pageSetup.BottomMargin = 0.3
        pageSetup.LeftMargin = 0.3
        pageSetup.RightMargin = 0.3

    workbook.ConverterSetting.SheetFitToPage = True
    workbook.SaveToFile(output_file, FileFormat.PDF)
    workbook.Dispose()
   
    print(f'File "{input_file}" converted to "{output_file}" and saved')


This works great when run locally on windows running python, but update the lambda source to use this function, build and run the container we get this in our docker logs:
GetDllLibXls().Workbook_CreateWorkbook.restype = c_void_p_PIREPath + pdfFile)orkbook_CreateWorkbook'
AND this response after a web request from the container
{"errorMessage": "'NoneType' object has no attribute 'Workbook_CreateWorkbook'", "errorType": "AttributeError", "requestId": "1f538bd0-c649-448e-b9f1-49b322f8fba6", "stackTrace": [" File \"/var/task/app.py\", line 156, in lambda_handler\n convert_sheets_to_pdf_SPIRE(input_file, output_file)\n", " File \"/var/task/app.py\", line 73, in convert_sheets_to_pdf_SPIRE\n workbook = Workbook()\n", " File \"/var/task/plum/function.py\", line 642, in __call__\n return self.f(self.instance, *args, **kw_args)\n", " File \"/var/task/plum/function.py\", line 592, in __call__\n return _convert(method(*args, **kw_args), return_type)\n", " File \"/var/task/spire/xls/Workbook.py\", line 17, in __init__\n GetDllLibXls().Workbook_CreateWorkbook.restype = c_void_p\n"]}


This looks like there are other dependencies need to run 'Spire.XLS - Python' within a container.

Any ideas on next steps or what is missing?

dave.rowett
 
Posts: 2
Joined: Tue Aug 29, 2023 4:08 pm

Wed Aug 30, 2023 6:38 am

Hi,

Thank you for your feedback .We appreciate your interest and apologize for any inconvenience caused by the error message you encountered.

Currently, our Spire.Xls for Python does not support Linux operating systems. However, we are pleased to inform you that our other products, such as DOC, PDF, and Presentation, support Linux usage. We understand the importance of Linux compatibility for our users and are actively working towards adding Linux support for Spire.Xls soon.

We sincerely appreciate your understanding and patience. Rest assured that once Spire.Xls for Python becomes compatible with Linux, we will promptly notify you. If you have any further questions or require assistance with any of our supported products, please feel free to reach out to us.

Thank you again for your interest in our products.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Fri Sep 15, 2023 6:22 am

Hi,

Thanks for your patience.
Glad to inform you that we just released Spire.XLS for Python 13.9.0, now it supports the Linux platform, you can upgrade to the new version and have a test.

Website link: https://www.e-iceblue.com/Download/Spire-XLS-Python.html

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Sep 21, 2023 7:12 pm

Excellent. Ty for the update.

With the existing code represented above, I only had to make a small modification to requirements and imports to get converted xls/xlsx => pdf output as expected.

Code: Select all
#Spire.XLS-for-Python
Spire.Xls
plum-dispatch==1.7.4


Code: Select all
from spire.xls import *
#from spire.common import *


This helps me complete my POC and I can present.

Again appreciations for the update.

dave.rowett
 
Posts: 2
Joined: Tue Aug 29, 2023 4:08 pm

Fri Sep 22, 2023 1:38 am

Hi,

Thanks for your feedback.
We are delighted to know that the version works for you. If you have any other questions, just feel free to contact us.

Have a nice day!

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.XLS