Microsoft® Conversione formato Excel tramite PHP

Importa ed esporta file Excel come formati di fogli di calcolo, Web, immagini e layout fisso

 

La libreria PHP Excel accelera i processi di programmazione e conversione dei fogli di calcolo supportando i formati più diffusi tra cui XLS, XLSX, XLSM, XLSB, XLTX, XLTM, CSV, SpreadsheetML, ODS. Consente inoltre di esportare file Excel allo PDF, XPS, HTML, MHTML, Semplice Formati di testo e immagini popolari come TIFF, JPG, PNG, BMP e SVG.

Converti Excel in XLSX, ODS, SXC e FODS utilizzando PHP

L’interconversione del formato del foglio di calcolo richiede solo il caricamento di un foglio di calcolo con un’istanza di Cartella di lavoro e salvare nuovamente nel formato desiderato selezionando il valore appropriato da Salva formato enumerazione.

Codice PHP per la conversione del formato file Excel
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// load the template file
$workbook = new Workbook("input.xlsx");

// save as XLSX, ODS, SXC & FODS formats
$workbook->save("output.xlsx", SaveFormat::Xlsx);
$workbook->save("output.ods", SaveFormat::Ods);
$workbook->save("output.scx", SaveFormat::Sxc);
$workbook->save("output.fods", SaveFormat::Fods);
 

Converti Excel in PDF, XPS, HTML e MD utilizzando PHP

Sono disponibili classi specializzate per controllare il processo di conversione per formati di output specifici come PdfSaveOptions per esportare file Excel come PDF, XpsSaveOptions per la conversione da Excel a XPS, HtmlSaveOptions per rendere Excel come HTML e MarkdownSaveOptions per la conversione da Excel a Markdown.

Codice PHP per Excel fino a PDF e formati Web
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// load the template file
$workbook = new Workbook("input.xlsx");


// save Excel in PDF_A_1_B format
$pdfOptions = new PdfSaveOptions();
$pdfOptions->setCompliance(PdfCompliance::PDF_A_1_B);
$workbook->save("output.pdf", pdfOptions);

// save Excel in XPS with 1 page per worksheet
$xpsOptions = new XpsSaveOptions();
$xpsOptions->setOnePagePerSheet(true);
$workbook->save("output.xps", xpsOptions);

// save Excel in HTML with images as Base64
$htmlOptions = new HtmlSaveOptions();
$htmlOptions->setExportImagesAsBase64(true);
$workbook->save("output.html", htmlOptions);

// save Excel in Markdown (MD) while retaining cell formatting
$mdOptions = new MarkdownSaveOptions();
$mdOptions->setFormatStrategy(CellValueFormatStrategy::CELL_STYLE);
$workbook->save("output.md", mdOptions);
 

Converti JSON in Excel ed Excel in JSON utilizzando PHP

Gli sviluppatori PHP possono caricare e convertire facilmente i file JSON in Excel in poche righe di codice. Allo stesso modo, i dati Excel possono essere esportati nei dati JSON.

Codice PHP per la conversione da JSON a Excel
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// Load your source json file
$workbook = new Workbook("Data.json");

//save file to xlsx format
$workbook->save("output.xlsx");
Codice PHP per la conversione da Excel a JSON
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// Load your source xlsx file
$workbook = new Workbook("input.xlsx");

// save file to json format
$workbook->save("Data.json");
 

Converti fogli di lavoro Excel in JPG, BMP, PNG e GIF utilizzando PHP

Ogni foglio di lavoro di un file Excel può essere convertito in diversi formati di immagine, call OpzioniImmagineOrStampa .setImageFormat per impostare il formato dell’immagine.

Codice PHP per la conversione da Excel a immagine
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// load template spreadsheet
$workbook = new Workbook("template.xlsx");

// create & set an instance of ImageOrPrintOptions
$options = new ImageOrPrintOptions();
// set output image type
$options->setImageType(ImageType::PNG);
// create SheetRender for first worksheet in the collection
$sheet = $workbook->getWorksheets()->get(0);
$sr = new SheetRender(sheet, options);
// render worksheet to image
$sr->toImage(0, "output.jpg")
 

Converti Excel in Word e PowerPoint utilizzando PHP

È possibile caricare qualsiasi foglio di calcolo e convertirlo nei file Word DOCX e PowerPoint PPTX durante l’utilizzo DocxSaveOptions & PptxSaveOptions classi come illustrato di seguito.

Codice PHP per la conversione da Excel a Word e PowerPoint
require_once("Java.inc"); 
require_once("lib/aspose.cells.php"); 
use aspose\cells;
use aspose\cells\Workbook; 

// load template spreadsheet
$workbook = new Workbook("template.xlsx");

// save spreadsheet as DOCX
$docxOptions = new DocxSaveOptions();
$workbook->save("output.docx", docxOptions);

// save spreadsheet as PPTX
$pptxOptions = new PptxSaveOptions();
$workbook->save("output.pptx", pptxOptions)