Jump to content

PHP Excel column width


grissom

Recommended Posts

Hi all

 

I've been putting together some code for automatically writing an Excel spreadsheet in PHP

 

A quick trawl around Google has led me to functions for opening and closing an Excel file, and writing numbers and text strings into cells.  All Working Well - So Far so Good.

 

The bit I'm missing is a PHP function to set the width of an excel column. Can anybody please help ?

 

Many thanks and all the best.

Link to comment
https://forums.phpfreaks.com/topic/160158-php-excel-column-width/
Share on other sites

As somebody whose been working on an Excel reader/writer for some years, I'd be very interested if you found an answer that actually worked.

The trouble is that it's very dependent on the font/size used for the cells, as explained by this article on the MS support site.

 

The best advice I can give is to look at how we do it in PHPExcel, and read the advice given in this posting on our forum.

Are you talking about the XML-based spreadsheets (the OOXML or XMLOO or whatever MS calls it)?

 

1) Open Excel 2007 (or later if there is one)

2) Create a worksheet, modify some column widths, add some data

3) Save as xlsx format

4) Close Excel

5) Rename file to have zip extension

6) Unzip the file

7) Reverse engineer!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.