コード例 #1
0
 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.";
 }
コード例 #2
0
 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.";
 }