def __init__(self): dataDir = Settings.dataDir + 'WorkingWithFiles/WorksheetToImage/' imageFormat = ImageFormat #Instantiate a workbook with path to an Excel file book = Workbook(dataDir + "Book1.xls") #Create an object for ImageOptions imgOptions = 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 = SheetRender(sheet, imgOptions) for i in range(sr.getPageCount()): #Generate an image for the worksheet sr.toImage(i, dataDir + "mysheetimg" + ".png") # Print message print "Images generated successfully."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithFiles/ConvertingToXPS/' saveFormat = SaveFormat workbook = Workbook(dataDir + "Book1.xls") #Get the first worksheet. sheet = workbook.getWorksheets().get(0) #Apply different Image and Print options options = ImageOrPrintOptions() #Set the Format options.setSaveFormat(saveFormat.XPS) # Render the sheet with respect to specified printing options sr = SheetRender(sheet, options) sr.toImage(0, dataDir + "out_printingxps.xps") #Save the complete Workbook in XPS format workbook.save(dataDir + "out_whole_printingxps", saveFormat.XPS) # Print message print "Excel to XPS conversion performed successfully."
def __init__(self): dataDir = Settings.dataDir + "WorkingWithFiles/WorksheetToImage/" imageFormat = ImageFormat # Instantiate a workbook with path to an Excel file book = Workbook(dataDir + "Book1.xls") # Create an object for ImageOptions imgOptions = 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 = SheetRender(sheet, imgOptions) for i in range(sr.getPageCount()): # Generate an image for the worksheet sr.toImage(i, dataDir + "mysheetimg" + ".png") # Print message print "Images generated successfully."
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithFiles/ConvertingWorksheetToSVG/' saveFormat = SaveFormat workbook = Workbook(dataDir + "Book1.xls") #Convert each worksheet into svg format in a single page. imgOptions = ImageOrPrintOptions() imgOptions.setSaveFormat(saveFormat.SVG) imgOptions.setOnePagePerSheet(True) #Convert each worksheet into svg format sheetCount = workbook.getWorksheets().getCount() #for(i=0; i<sheetCount; i++) for i in range(sheetCount): sheet = workbook.getWorksheets().get(i) sr = SheetRender(sheet, imgOptions) pageCount = sr.getPageCount() #for (k = 0 k < pageCount k++) for k in range(pageCount): #Output the worksheet into Svg image format sr.toImage(k, dataDir + sheet.getName() + ".out.svg") # Print message print "Excel to SVG conversion completed successfully."