public static function run($dataDir = null) { $saveFormat = new SaveFormat(); $workbook = new Workbook($dataDir . "Book1.xls"); //Get the first worksheet. $sheet = $workbook->getWorksheets()->get(0); //Apply different Image and Print options $options = new ImageOrPrintOptions(); //Set the Format $options->setSaveFormat($saveFormat->XPS); // Render the sheet with respect to specified printing options $sr = new 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."; }
public static function run($dataDir = null) { $imageFormat = new ImageFormat(); //Instantiate a new workbook with 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"); } // Print message print "Images generated successfully." . PHP_EOL; }
public static function run($dataDir = null) { $saveFormat = new SaveFormat(); $path = $dataDir . "Template.xlsx"; //Create a workbook object from the template file $workbook = new Workbook($path); //Convert each worksheet into svg format in a single page. $imgOptions = new ImageOrPrintOptions(); $imgOptions->setSaveFormat($saveFormat->SVG); $imgOptions->setOnePagePerSheet(true); //Convert each worksheet into svg format $sheetCount = $workbook->getWorksheets()->getCount(); for ($i = 0; $i < $sheetCount; $i++) { $sheet = $workbook->getWorksheets()->get($i); $sr = new SheetRender($sheet, $imgOptions); $pageCount = $sr->getPageCount(); for ($k = 0; $k < $pageCount; $k++) { //Output the worksheet into Svg image format $sr->toImage($k, $path . $sheet->getName() . $k . ".out.svg"); } } // Print message print "Excel to SVG conversion completed successfully."; }