在phpexcel中,如何用名称工作表?
删除表格我有这个,但它不起作用:
$objWorkSheet->removeSheetByIndex("Worksheet");
Worksheet
是工作表的名称,而不是其索引(位于工作表集合中)。您需要确定其索引位置并将其用作removeSheetByIndex()
类似:
$objWorkSheet->setActiveSheetIndexByName('Worksheet');
$sheetIndex = $objWorkSheet->getActiveSheetIndex();
$objWorkSheet->removeSheetByIndex($sheetIndex);
或
$objWorkSheet->removeSheetByIndex(
$objWorkSheet->getIndex(
$objWorkSheet->getSheetByName('Worksheet')
)
);