Arbeitsblätter verwalten in Php
Contents
[
Hide
]
Aspose.Cells – Verwalten von Arbeitsblättern
Hinzufügen von Arbeitsblättern zu einer neuen Excel-Datei
Um ein Arbeitsblatt zu einer neuen Excel-Datei hinzuzufügen, verwenden SieAspose.Cells Java for PHP , einfach anrufenadd_worksheet Methode vonArbeitsblätter verwalten Modul.
PHP-Code
//Instantiating a Workbook object
$workbook = new Workbook();
//Adding a new worksheet to the Workbook object
$worksheets = $workbook->getWorksheets();
$sheetIndex = $worksheets->add();
$worksheet = $worksheets->get($sheetIndex);
//Setting the name of the newly added worksheet
$worksheet->setName("My Worksheet");
//Saving the Excel file
$workbook->save($dataDir . "book.out.xls");
Entfernen von Arbeitsblättern unter Verwendung des Blattnamens
So entfernen Sie Arbeitsblätter nach Blattnamen mitAspose.Cells Java for PHP , einfach anrufenremove_worksheet_by_name Methode vonArbeitsblätter verwalten Modul.
PHP-Code
//Creating a file stream containing the Excel file to be opened
$fstream = new FileInputStream($dataDir . "book.xls");
//Instantiating a Workbook object with the stream
$workbook = new Workbook($fstream);
//Removing a worksheet using its sheet name
$workbook->getWorksheets()->removeAt("Sheet1");
//Saving the Excel file
$workbook->save($dataDir . "book.out.xls");
//Closing the file stream to free all resources
$fstream->close();
Arbeitsblätter mit Blattindex entfernen
Um Arbeitsblatt für Blattindex zu entfernen, verwenden SieAspose.Cells Java for PHP , einfach anrufenremove_worksheet_by_index Methode vonArbeitsblätter verwalten Modul.
PHP-Code
//Creating a file stream containing the Excel file to be opened
$fstream=new FileInputStream($dataDir . "book.xls");
//Instantiating a Workbook object with the stream
$workbook = new Workbook($fstream);
//Removing a worksheet using its sheet index
$workbook->getWorksheets()->removeAt(0);
//Saving the Excel file
$workbook->save($dataDir . "book.out.xls");
//Closing the file stream to free all resources
$fstream->close();
Laufcode herunterladen
Download**Arbeitsblätter verwalten (Aspose.Cells)**von einer der unten genannten Social-Coding-Sites: