在Ruby中将工作表转换为图像
Contents
[
Hide
]
Aspose.Cells - 将工作表转换为图像
使用Ruby中的Aspose.Cells for Java将工作表转换为图像,只需调用Converter模块。
Ruby 代码
def worksheet_to_image(workbook)
#Create an object for ImageOptions
img_options = Rjb::import('com.aspose.cells.ImageOrPrintOptions').new
# Set the image type
image_format = Rjb::import('com.aspose.cells.ImageFormat')
img_options.setImageFormat(image_format.getPng())
# Get the first worksheet.
sheet = workbook.getWorksheets().get(0)
# Create a SheetRender object for the target sheet
sr = Rjb::import('com.aspose.cells.SheetRender').new(sheet, img_options)
j = 0
while j < sr.getPageCount()
# Generate an image for the worksheet
sr.toImage(j, @data_dir + "mysheetimg_#{j}.png")
j +=1
end
puts "Image saved successfully."
end
下载运行代码
从以下任何社交编码网站下载将工作表转换为图像(Aspose.Cells):