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
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.