php excel 批注,在xlsx文件中找不到phpexcel注释

使用此代码,我可以在excel文件中创建注释.

$comment = $data_sheet->getCommentByColumnAndRow($col, 1);

$comment->setAuthor($table_name . '.' . $field_name);

$comment->setWidth('200px');

$comment->setHeight('24px');

$comment->setVisible(false); # ActiveCell.Comment.Visible = True

$objCommentRichText = $comment->getText()->createTextRun($table_name . '.' . $field_name);

保存时,文件中包含注释,可以对其进行编辑,但是在重新打开该文件时,注释对象处于默认状态.

$comment = $data_sheet->getComment('A1');

结果是:-

$comment = PHPExcel_Comment Object (

[_author:private] => Author

[_text:private] => PHPExcel_RichText Object ( [_richTextElements:private] => Array ( ) )

[_width:private] => 96pt

[_marginLeft:private] => 59.25pt

[_marginTop:private] => 1.5pt

[_visible:private] =>

[_height:private] => 55.5pt

[_fillColor:private] => PHPExcel_Style_Color Object (

[_argb:private] => FFFFFFE1

[_isSupervisor:private] =>

[_parent:private] =>

[_parentPropertyName:private] =>

)

)

编辑:

products.products_idproducts.part_codeproducts.products_nameproducts.products_quantityproducts.products_statusproducts.costproducts.cost_modifierproducts.delivery_costproducts.shipping_strategyproducts.products_weightproducts.shipping_amountproducts.products_priceproducts.rrpproducts.tradeproducts_feed.amazon_priceproducts_feed.ebay_price

products.products_id

products.part_code

products.products_name

products.products_quantity

products.products_status

products.cost

products.cost_modifier

products.delivery_cost

products.shipping_strategy

products.products_weight

products.shipping_amount

products.products_price

products.rrp

products.trade

products_feed.amazon_price

products_feed.ebay_price

因此,注释存在于.xlsx文件中.

这些都还没有收到评论.

$comment = $data_sheet->getCommentByColumnAndRow($col, 1);

$comment = $data_sheet->getComment('A'. $row);

$comments = $data_sheet->getComments();

– 编辑

问题,注释是否正确以“ Excel2007”格式加载?

解决方法:

这是我使用PHPExcel从单元格中提取注释的代码片段

$objPHPExcel = PHPExcel_IOFactory::load("MyExcelFile.xlsx");

$objWorksheet = $objPHPExcel->getActiveSheet();

// loop through each row in excel file

foreach ($objWorksheet->getRowIterator() as $row) {

$cellIterator = $row->getCellIterator();

$cellIterator->setIterateOnlyExistingCells(true);

// loop through each column in row

foreach ($cellIterator as $cell) {

// get the value of the cell

$value = $cell->getValue();

// get the comment in the cell (if a comment exists)

$comment = $objWorksheet->getComment($cell->getCoordinate())->getText();

}

}

标签:phpexcel,php

来源: https://codeday.me/bug/20191023/1915627.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值