简体   繁体   English

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

[英]is text overflow will work in phpspreadsheet?

The problem I am facing is, I am not able to set cell value as text-overflow (not clipped or wrapped). 我面临的问题是,我无法将单元格值设置为文本溢出(未修剪或包装)。 It is always hiding with a red triangle sign in Libre Calc. 它在Libre Calc中始终隐藏着红色三角形符号。

I have a sample .xls sheet that I need to replicate dynamically. 我有一个示例.xls工作表,我需要动态复制它。 I got successful in generating the same .xls sheet using PHPSpreadsheet library in Codeigniter framework. 我在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);

The Text in the cell always gets hide when I see it in office 365 and Libre Calc. 当我在Office 365和Libre Calc中看到该单元格中的文本时,该文本总是隐藏起来。 I need to double click to show it fully. 我需要双击以完整显示它。 But I need it shows fully. 但我需要它充分显示。

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

You have to use 你必须用

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

For more Information see documentation . 有关更多信息,请参见文档

According to this comit this comit this will be automaticly included in future releases. 根据此承诺, 此承诺将自动包含在将来的版本中。

Maybe you must/will use some autofit then take a look to this code . 也许您必须/将使用一些自动调整功能,然后查看此代码

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

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