繁体   English   中英

是文本溢出将在phpspreadsheet中工作?

[英]is text overflow will work in phpspreadsheet?

我面临的问题是,我无法将单元格值设置为文本溢出(未修剪或包装)。 它在Libre Calc中始终隐藏着红色三角形符号。

我有一个示例.xls工作表,我需要动态复制它。 我在Codeigniter框架中使用PHPSpreadsheet库成功生成了相同的.xls表。

$spreadsheet = new Spreadsheet();

$sheet = $spreadsheet->getActiveSheet();

$sheet->setTitle('1');

$sheet->getPageSetup()->setOrientation(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE);
$sheet->getPageSetup()->setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4);

$query_date = $data['month_selected'].' '.$data['year_selected'];

$date = new DateTime($query_date);

$date->modify('first day of this month');
$firstday= $date->format('n/j/Y');

$date->modify('last day of this month');
$lastday= $date->format('n/j/Y');

$xrow = 1;
$sheet->setCellValue('A' . $xrow, 'Attedence for the Period Beginning From '.$firstday.' TO '.$lastday)->getStyle('I' . $xrow)->applyFromArray($borderArrayRowOther);

当我在Office 365和Libre Calc中看到该单元格中的文本时,该文本总是隐藏起来。 我需要双击以完整显示它。 但我需要它充分显示。

[重叠的文字] [1]: https//i.stack.imgur.com/zi3Pj.png

你必须用

$spreadsheet->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);

有关更多信息,请参见文档

根据此承诺, 此承诺将自动包含在将来的版本中。

也许您必须/将使用一些自动调整功能,然后查看此代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM