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