找到php工作表,php – 工作表标题中找到无效字符

这篇博客揭示了如何在PHPExcel 1.7.8版本中修改checkSheetTitle()函数,避免抛出异常,通过替换无效字符修复了不合规的sheet名称。作者虽然不推荐此做法,但这种临时解决方案对当前工作有帮助。
摘要由CSDN通过智能技术生成

我们刚刚完成此操作以使其现在排序.它可能非常糟糕,我不会真的建议其他人这样做,但是嘿,它应该对我们有用!

在PHPExcel的1.7.8版本中,在第414行的/Classes/PHPExcel/Worksheet.php中 – 交换checkSheetTitle()函数以进行以下操作:

private static function _checkSheetTitle($pValue)

{

// Some of the printable ASCII characters are invalid: * : / \ ? [ ]

if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {

//throw new Exception('Invalid character found in sheet title');

//Hack to remove bad characters from sheet name instead of throwing an exception

return str_replace(self::$_invalidCharacters, '', $pValue);

}

// Maximum 31 characters allowed for sheet title

if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {

throw new Exception('Maximum 31 characters allowed in sheet title.');

}

return $pValue;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值