We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Python Flask Web server Hang at Aspose.Cells

Hello,

I am developing Excel encryption with Aspose.Cells but hang occurred in Aspose.Cells library call.

Weired thing is it works on Python console, but only not working in Web server condition.

There is no any error message and debug message, so I cannot debug this problem.

Here is my code.

from openpyxl import Workbook
from asposecells.api import Workbook as eWorkbook, EncryptionType    

with NamedTemporaryFile(suffix='.xlsx', mode='w+') as output:
        wb = Workbook(write_only=True)
        ws = wb.create_sheet()
        ws.auto_filter.ref = f'A5:J10'
        ws.freeze_panes = 'A6'

        # ~~~~ append rows code ~~~~

        wb.save(output.name)
        output.seek(0)

        jwb = eWorkbook(output.name)  # Hang occurred in here !!

        jwb.getSettings().setPassword("1234")
        jwb.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128)
        encrypted = NamedTemporaryFile(suffix='.xlsx', mode='w+')
        jwb.save(encrypted.name)
        encrypted.close()

@taylor224,
We are working on this issue and will share our feedback soon.

@taylor224,
We need further information in this regard. Could you please share a complete runnable simplified project that contains only this code and contains all the required references? Share the IDE, operating system, web server details and template files (if any) also for testing this issue here.

@taylor224,
We have further investigated this issue and established the environment such that the following sample code runs and displays the message “Hello World” in web browser using url "http://127.0.0.1:5000".

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello world!'

Now when we try your sample code, we get the following error:

 * Serving Flask app 'hello.py' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'hello', an ImportError was raised:

Traceback (most recent call last):
  File "/Users/testuser/Flask/FirstFlaskApp/lib/python3.9/site-packages/flask/cli.py", line 256, in locate_app
    __import__(module_name)
  File "/Users/testuser/Flask/FlaskTest/hello.py", line 1, in <module>
    from openpyxl import Workbook
ModuleNotFoundError: No module named 'openpyxl'

Could you please share how to resolve this errror? We need the exact content of your application folder for our reference.

@taylor224

We create a Flask Web demo with your code, it works OK. Don’t forget import asposecells at the start.
Code: hello.zip (727 Bytes)

@taylor224,
For further investigation we have logged a ticket in our issue tracking system. You may please give a try to the sample code suggested by @Peyton.Xu and share your feedback.

This issue is logged as:
CELLSJAVA-43550 - Python Flask Web server Hang at Aspose.Cells