Can you please provide me with examples of using Aspose.Cells for .NET in a python file? I also could not install this package - so I unzipped “aspose_cells_python-24.11.0-py3-none-win_amd64.whl” file manually and installed it in the same folder as my python test script file.
Any and all help with an installation starting point and code samples that work would be very helpful. Thank you.
It said downloading aspose_cells_python-24-11.0-py3-none-win_amd64.whl … etc. and then in a lower line: 3.4 of 62.2 etc. eta 0:01:16. And it stayed there for more than 30 minutes! I can attach a screenshot if you will give me a link to upload it
@nvartak
Normally, we use pip install aspose-cells-python to install the latest version. If the installation fails due to network delays or other reasons, you can also download a specific version here for local installation.
After multiple tries, I got Aspose.Cells for Python via .NET installed here: “C:\Users<myprofilename>\AppData\Local\Programs\Python\Python313\Lib\site-packages\aspose\assemblies\cells”.
However, when I try to code “import aspose.cells” or “from aspose.cells import License, Workbook” in my Python file which exists here: “C:\Users<myprofilename>\Documents\xyz\abc\bot_aspose_test.py”, I get warning in VS Code for this file.
What am I doing wrong? Please note that I am not an Admin on my laptop and unable to register any dll or put it in environment path variable.
@nvartak
1.Please first check if aspose-cells-python version 24.11 is correctly installed by running pip list aspose-cells-python, as Python 3.13 is supported starting from version 24.11.
2.Also, could you specify the exact warning message you are seeing?
3.Finally, if you have confirmed that Aspose.Cells for Python 24.11 is correctly installed, you can run examples from PyPI in ipython to verify.
4.Here is the step-by-step explanation of how I installed and tested Aspose.Cells for Python to support Python 3.13:.
I have also confirmed that 24.11.0 version of aspose-cells-python is installed - in this case also, a new window pops up and closes - fortunately, I was able to get a quick snapshot before it closed. Why is this happening?
I typed cmd: py -3.13 -m pip install aspose-cells-python
The message said: requirement already satisfied: aspose-cells-python in .\appdata\local\programs\python\python313\lib\site-packages (24.11.0)
@nvartak
By testing with the following sample code, we can find that there are no error prompts in Pycharm. There will be error prompts in the VS code, but it does not affect the program’s operation. Running the program directly can get correct results. We need to further investigate the reasons for the error message, and we will notify you promptly once there is an update. Please refer to the attachment. vs_code.png (22.5 KB) Pycharm.png (81.6 KB) pivotTable_test_out.zip (9.3 KB)
import aspose.cells
from aspose.cells import Workbook
from aspose.cells.pivot import PivotFieldType
# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the newly added worksheet
sheet = workbook.worksheets[0]
cells = sheet.cells
# Setting the value to the cells
cell = cells.get("A1")
cell.put_value("Sport")
cell = cells.get("B1")
cell.put_value("Quarter")
cell = cells.get("C1")
cell.put_value("Sales")
cell = cells.get("A2")
cell.put_value("Golf")
cell = cells.get("A3")
cell.put_value("Golf")
cell = cells.get("A4")
cell.put_value("Tennis")
cell = cells.get("A5")
cell.put_value("Tennis")
cell = cells.get("A6")
cell.put_value("Tennis")
cell = cells.get("A7")
cell.put_value("Tennis")
cell = cells.get("A8")
cell.put_value("Golf")
cell = cells.get("B2")
cell.put_value("Qtr3")
cell = cells.get("B3")
cell.put_value("Qtr4")
cell = cells.get("B4")
cell.put_value("Qtr3")
cell = cells.get("B5")
cell.put_value("Qtr4")
cell = cells.get("B6")
cell.put_value("Qtr3")
cell = cells.get("B7")
cell.put_value("Qtr4")
cell = cells.get("B8")
cell.put_value("Qtr3")
cell = cells.get("C2")
cell.put_value(1500)
cell = cells.get("C3")
cell.put_value(2000)
cell = cells.get("C4")
cell.put_value(600)
cell = cells.get("C5")
cell.put_value(1500)
cell = cells.get("C6")
cell.put_value(4070)
cell = cells.get("C7")
cell.put_value(5000)
cell = cells.get("C8")
cell.put_value(6430)
pivotTables = sheet.pivot_tables
# Adding a PivotTable to the worksheet
index = pivotTables.add("=A1:C8", "E3", "PivotTable2")
# Accessing the instance of the newly added PivotTable
pivotTable = pivotTables[index]
# Unshowing grand totals for rows.
pivotTable.row_grand = False
# Draging the first field to the row area.
pivotTable.add_field_to_area(PivotFieldType.ROW, 0)
# Draging the second field to the column area.
pivotTable.add_field_to_area(PivotFieldType.COLUMN, 1)
# Draging the third field to the data area.
pivotTable.add_field_to_area(PivotFieldType.DATA, 2)
# Saving the Excel file
workbook.save("pivotTable_test_out.xlsx")
@nvartak
Please visit the following link to purchase related products. You can also check the Purchase section at the top of the page for more information.
For information about License, please refer to the following document.
Thank you. We have a current & valid Aspose.Total.NET license which I tried to use using the information provided in the licensing link, but it gave me this error in PyCharm debugger:
File “C:\Program Files\JetBrains\PyCharm 2024.3\plugins\python-ce\helpers\pydev_pydev_imps_pydev_execfile.py”, line 18, in execfile
exec(compile(contents+“\n”, file, ‘exec’), glob, loc)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\myusername\Documents\mytestscriptfile.py”, line 12
license.set_license(“C:\Users<myusername>\Documents\Aspose.Total.NET.lic”);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
python-BaseException
Since you are trying to use Aspose.Total for .NET license with Aspose.Cells for Python via .NET API, so you will get error as this license is not valid for Aspose.Cells for Python APIs, this license is valid for Aspose.Total for .NET APIs. You would either need to have Aspose.Total for Python via .NET license to work with all Aspose.Total for Python via .NET APIs or Aspose.Cells for Python via .NET license to work with Aspose.Cells for Python via .NET API.
The first backslash in license path string is being interpreted as a special character. In fact, because it’s followed by a “U”, it’s being interpreted as the start of a Unicode code point.