Converting Worksheet to Image in PHP

Aspose.Cells - Converting Worksheet to Image

To convert a worksheet to an image using Aspose.Cells for Java in PHP, simply invoke the Converter module.

PHP Code

$imageFormat = new ImageFormat();

// Instantiate a new workbook with the path to an Excel file
$book = new Workbook($dataDir . "MyTestBook1.xls");

// Create an object for ImageOptions
$imgOptions = new 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 = new SheetRender($sheet, $imgOptions);

for ($j = 0; $j < $sr->getPageCount(); $j++) {
    // Generate an image for the worksheet
    $sr->toImage($j, $dataDir . "mysheetimg" . $j . ".png");
}

Download Running Code

Download Converting Worksheet to Image (Aspose.Cells) from any of the below-mentioned social coding sites: