如何在phpexcel中删除工作表



在phpexcel中,如何用名称工作表

删除表格

我有这个,但它不起作用:

$objWorkSheet->removeSheetByIndex("Worksheet");

Worksheet是工作表的名称,而不是其索引(位于工作表集合中)。您需要确定其索引位置并将其用作removeSheetByIndex()

的参数

类似:

$objWorkSheet->setActiveSheetIndexByName('Worksheet');
$sheetIndex = $objWorkSheet->getActiveSheetIndex();
$objWorkSheet->removeSheetByIndex($sheetIndex);

$objWorkSheet->removeSheetByIndex(
    $objWorkSheet->getIndex(
        $objWorkSheet->getSheetByName('Worksheet')
    )
);

最新更新