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

Free Support Forum - aspose.com

Install Aspose.Cells Java for Python to Convert Excel Worksheets into Image Files

Hi,
I am trying to setup Aspose.Cells Java for Python so I can convert excel worksheets into image files.
As needed, I have installed Jpype onto my Mac, and have moved on to installing Aposte.Cells for Java. I have the file ‘aspose-cells-17.7-java.zip’, but when I try to unzip it just creates a new zipped file, and when I try to unzip that, it creates another zip file. I have an endless loop of zips!
If anyone could be of any help in solving this issue it would be much appreciated. I only found out about this software about 30mins ago and frankly have no idea what I’m doing.

Best,
mr boiddims

@mrboiddims,

There is no endless loop if zips. Actually Aspose.Cells for Java does provide spreadsheet management/conversion library and a separate grid control (Aspose.Cells.GridWeb (JAVA)). Moreover, zipped archive also includes HTML API reference documentation, text files and some other resource files for both Aspose.Cells library and JSP/Servlets based Grid control.
I have pasted the complete details with screenshots for aspose-cells-17.7-java.zip release archive for your requirements:
Step1:
The release archive “aspose-cells-17.7-java.zip” is extracted into two files:

Step2:
JDK 1.6 folder contains two zipped files:

Step3:
Please open internal “aspose-cells-17.7-java” zipped file that contains the following folders:

Step4:
lib folder contains Aspose.Cells for Java component’s JAR files which you should use:

Hope it helps a bit.

Thank you.

Thanks for your help!

What exactly do I do with the Jar file now?
(Sorry)

EDIT:
I found it! I put the two jar files in /Applications/lib, but for some reason when I run my code I still get the error:

You need to put your Aspose.Cells for Java APIs .jars in this folder:
/Applications/lib/

EDIT 2:
I don’t think that is an error, I think it just displays ever time.
However, nothing happens. I am running the code to convert Excel sheet --> image but nothing is happening.

@mrboiddims,

Could you paste the sample code here. Also, we recommend you to kindly see the document for your reference on how to convert an Excel sheet to image file in JAVA:
https://docs.aspose.com/display/cellsjava/Converting+Worksheet+to+Different+Formats

Also, you may browse different topics/examples for your reference on configuring and using Aspose.Cells in Python:
https://docs.aspose.com/display/cellsjava/Aspose.Cells+Java+for+Python

Thank you.

Hi,
Again thanks for your help.
I am running the code given in the demo I downloaded from Github.

I combined the init.py and main .py file together as I was getting an error about the init file not being imported correctly.

import jpype
import os.path

class WorksheetToImage:

def __init__(self,dataDir):
    self.dataDir = dataDir
    self.Workbook = jpype.JClass("com.aspose.cells.Workbook")
    self.ImageFormat = jpype.JClass("com.aspose.cells.ImageFormat")
    self.ImageOrPrintOptions = jpype.JClass("com.aspose.cells.ImageOrPrintOptions")
    self.SheetRender = jpype.JClass("com.aspose.cells.SheetRender")

def main(self):

    imageFormat = self.ImageFormat

    #Instantiate a workbook with path to an Excel file
    book = self.Workbook(self.dataDir + "Book1.xls")

    #Create an object for ImageOptions
    imgOptions = self.ImageOrPrintOptions()

    #Set the image type
    imgOptions.setImageFormat(imageFormat.getPng())

    #Get the first worksheet.
    sheet = book.getWorksheets().get(0)

    #Create a SheetRender object for the target sheet
    sr =self.SheetRender(sheet, imgOptions)
    for i in range(sr.getPageCount()):

        #Generate an image for the worksheet
        sr.toImage(i, self.dataDir + "mysheetimg" + ".png")


    # Print message
    print "Images generated successfully."


asposeapispath = os.path.join(os.path.abspath("../../../"), "lib/")
dataDir = os.path.join(os.path.abspath("./"), "data/")

print "You need to put your Aspose.Cells for Java APIs .jars in this folder:\n"+asposeapispath

#print dataDir
jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.ext.dirs=%s" % asposeapispath)

hw = WorksheetToImage(dataDir)
hw.main()

When I run this code, it just returns

You need to put your Aspose.Cells for Java APIs .jars in this folder:
/Applications/lib/

and nothing else happens.

EDIT:
If I run the python file of any of the examples, it gives me an error such as “ImportError: No module named quickstart” (for the HelloWorld) example. For some reason I can’t import the init file

@mrboiddims,

You meant the image (for the sheet) is not generated in the specified folder. I am not sure if the issue is related to Aspose.Cells for Java but the issue can be related to configurations, etc. You may take some help browsing internet. For example, see the documents/threads for your reference:


Thank you.