Hantera arbetsblad i Php

Aspose.Cells - Hantera arbetsblad

Lägga till kalkylblad till en ny Excel-fil

För att lägga till kalkylblad i en ny Excel-fil medAspose.Cells Java for PHP , ring helt enkeltadd_worksheet metod avHantera arbetsblad modul.

PHP-kod

 //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");

Ta bort kalkylblad med Sheet Name

För att ta bort kalkylblad efter arknamn medAspose.Cells Java for PHP , ring helt enkeltremove_worksheet_by_name metod avHantera arbetsblad modul.

PHP-kod

 //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();

Ta bort kalkylblad med Sheet Index

För att ta bort kalkylblad för ark index medAspose.Cells Java for PHP , ring helt enkeltremove_worksheet_by_index metod avHantera arbetsblad modul.

PHP-kod

 //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();

Ladda ner Running Code

Ladda ner**Hantera arbetsblad (Aspose.Cells)**från någon av nedan nämnda webbplatser för social kodning: