使用PHPExcel设置电子表格单元格的宽度 [英] Setting width of spreadsheet cell using PHPExcel

查看:1097
本文介绍了使用PHPExcel设置电子表格单元格的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过以下方式设置用PHPExcel生成的Excel文档中单元格的宽度:

I'm trying to set the width of a cell in an Excel document generated with PHPExcel with:

$objPHPExcel->getActiveSheet()->getColumnDimensionByColumn('C')->setWidth('10');
$objPHPExcel->getActiveSheet()->getColumnDimensionByColumn('C')->setAutoSize(false);

但这不起作用.

我需要在这里调用什么方法?

What is the method that I need to call here?

推荐答案

这是一个细微的区别,但这对我来说很好:

It's a subtle difference, but this works fine for me:

$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);

注意,getColumnDimensionByColumngetColumnDimension

此外,我什至都没有设置AutoSize,而且效果很好.

Also, I'm not even setting AutoSize and it works fine.

这篇关于使用PHPExcel设置电子表格单元格的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆