Python interop for XLSX- PPTX

Hi,

I was able to convert a DOCX file to PDF using a python interop through Aspose for .NET. And now, I want an XLSX file to be converted to PDF through a Python interop. However, according to the documentation it says that I need to register Aspose.Cells.Interop.dll as

regasm Aspose.Cells.Interop.dll /codebase
http://www.aspose.com/docs/display/cellsnet/Using+the+COM+Interface

However, aspose.cells.interop.dll is not found in my aspose installation directory. As a result I am stuck with the conversion.

I have a similar issue with a PPTX conversion. Can you please let me know how to proceed?

Thanks,
Ram

Hi Ram,

Thanks for your posting and using Aspose APIs.

You do not need Aspose.Cells.Interop.dll. Please get the Aspose.Cells dll from net2.0 folder of the installation directory from the latest version: Aspose.Cells for .NET 8.4.0 and register it like this

regasm Aspose.Cells.dll /codebase

and it will resolve your issue.

Hi,

Thanks for the reply. Can you please share PHP/Python interop for conversion please? The one that you guys have in the documentation ain’t working for me.

Hi,

Thanks for your posting and using Aspose.Cells.

Actually, we need to review and update the documentation page. There is no separate interop dll. Now you will have to use Aspose.Cells.dll only.

Hi Shakeel,

I understand that. Today, I am not able to load an already existing xls file in Python using
win32com.client.Dispatch(‘Aspose.Cells.Workbook’)

Only after loading the file I will be able to convert it to PDF, right? Do you have any code samples either in PHP/Python? The documentation page you have seems quite out dated and I would like to know the new way of doing this.

Hi,

Thanks for your posting and using Aspose.Cells.

We will look into this issue and let you know the Python code. However, could you meanwhile convert the following VB script into Python because the approach should be similar.

The following VB script creates a Workbook object with some text in cell A1. I have also attached the output Excel file generated by it for your reference.

VB Script
Dim xls
Set xls = CreateObject(“Aspose.Cells.Workbook”)

'Put data into the workbook
Dim sheet
’Get the first worksheet (default worksheet)
Set sheet = xls.worksheets.item(0)

Dim cells
Set cells = sheet.cells
Dim cell
Set cell = cells.item_3(“A1”)
cell.PutValue “Hello World!”

'Save the document
xls.Save “output.xls”

Hi Shakeel,

Thanks for the reply. As you see you are creating an xls workbook as you know what data you have to put in there. For us the case is that we do not know what the xls file contains. We also aren’t interested in reading the xls file as its our users files. All we wanted to do is to feedAspose.Cells with the xls file and wanted Aspose to convert the file to PDF.

For instance, our Aspose.Word implementation looks like this
import win32com.client

helper = win32com.client.Dispatch('Aspose.Words.ComHelper')
doc = helper.Open('input.docx')
doc.Save('output.pdf')



We wanted to do a similar thing with both Aspose.Cells and Aspose.Slides.

Can you please help?

Hi,

Thanks for your posting and using Aspose.Cells.

You can use Aspose.Cells for Cloud for the same purpose. It is language independent and you can convert your Excel file into PDF using it with Python.

Please read the following product pages to get familiar with the Cloud APIs.


Shakeel,

We do not want to send our user documents externally for conversion. That was the reason for us to install Aspose.Net on our test server. If you think that it is not possible for us to convert XLS and PPT files using interop, then I think we would NOT be able to buy your license.

We were thinking that it is easy for us to do the conversion with Aspose. Please get back to me after consulting your tech team as our OEM purchase really depends on the possibility to do the PDF conversion as an interop.

Hi,

Thanks for your posting and considering Aspose.

Sure, we will look into it and get back to you. Meanwhile for your issue related to PPT(Aspose.Slides), please post your question in Aspose.Slides forum so that Aspose.Slides team could also look into your issue and help you with your question.

Thanks for your cooperation.

hi ram0812!

I think following link
http://www.aspose.com/docs/display/cellsnet/Using+the+COM+Interface
could be helpful for you.

Hi,

Thanks for your posting and using Aspose.Cells.

I wrote the following Python script which creates a
workbook, writes a string in cell A1 of first worksheet and saves the
workbook in pdf format. It works fine. However, when I tried to open the existing Excel document, I could not find any way.

Earlier there was “Aspose.Cells.Interop.InteropHelper” i.e Aspose.Cells.Interop.dll that could be
used for this purpose but now there is no such dll. Also workbook does
not have any open method too.


We have therefore logged a New Feature request in our database to support this feature. We will look into it and implement it if possible. Once, it will be available or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43504 - Open existing Excel document using COM (Component Object Model)

I have attached the output PDF generated by the following Python script for a reference.

Python

import win32com.client

workbook=win32com.client.Dispatch(“Aspose.Cells.Workbook”)

worksheets = workbook.Worksheets

worksheet = worksheets.item(0)

cells = worksheet.Cells

cell = cells.item_3(“A1”)

cell.putvalue(“Welcome to Aspose - Python”)

workbook.save(“output.pdf”)

Hi Wang Qi,

Thanks for the link Wang. I did check out that page before posting. As said earlier, Aspose.Cells.Interop.dll is missing from my installation. As you say Wang, if we have that DLL we would be able to load an existing XLS file and convert it to PDF. The unfortunate part is that I am not able to difn the dll on my machine. Do you have that DLL in your machine?


Shakeel, the example you provided is for creating a new workbook and creating your own data. Please help me with loading an existing xls file using interop.

Ram
Hi Ram,

ram0812:
Hi,
However, according to the documentation it says that I need to register Aspose.Cells.Interop.dll as

regasm Aspose.Cells.Interop.dll /codebase
http://www.aspose.com/docs/display/cellsnet/Using+the+COM+Interface

However, aspose.cells.interop.dll is not found in my aspose installation directory. As a result I am stuck with the conversion.

Please find attached the Aspose.Cells.Interop.Dll file used the document for your requirements.

Thank you.

Amjad,

Thanks for the link. This is it. It is exactly what I was looking for. I will try the interop and get back to you guys.

Thanks again!

Hi Ram,

Thanks for your posting and using Aspose.Cells.

It is good to know that you got the Aspose.Cells Interop DLL. Please try it and let us know how it goes at your end. In case of any issues, let us know. We will look into it and help you further.