在PHP中将工作表转为图像
Contents
[
Hide
]
Aspose.Cells - 将工作表转换为图像
将 Microsoft Excel 工作表转换为图像文件
PHP 代码
$dataDir = '';
// Create Aspose.Cells Helper Object
$ptr = new \COM('Aspose.Cells.Interop.InteropHelper');
// Opening through Path
// Creating a Workbook object and opening an Excel file using its file path
$workbook = $ptr->New("Aspose.Cells.Workbook",array($dataDir . '/MyTestBook1.xls'));
$worksheets = $ptr->Get($workbook,"Worksheets",array());
$sheet = $ptr->Get($worksheets,'Item',array(0));
$imgOptions = $ptr->New("Aspose.Cells.Rendering.ImageOrPrintOptions",array());
$imageFormat = new \DOTNET('mscorlib', 'System.Drawing.Imaging.ImageFormat');
$ptr->Set($imgOptions,'ImageFormat',$imageFormat->Jpeg,array());
$ptr->Set($imgOptions,'OnePagePerSheet',true,array());
$sr = $ptr->New("Aspose.Cells.Rendering.SheetRender",array($sheet,$imgOptions));
$bitmap = new \DOTNET("mscorlib", "System.Drawing.Bitmap");
$bitmap->Save($dataDir . "./SheetImage.jpg");
print "Conversion to Image(s) completed!" . PHP_EOL;
下载运行代码
从以下任何社交编码网站下载 Worksheet to Image (Aspose.Cells):