hypertensy
hypertensy

Reputation: 235

Length of cells depending on the length of the string in Excel/CSV

Recently I mastered fgetcsv in the hope of writing an array to a file so that I could later open it via Excel, there was no problem with it. Everything turned out ok. But, as far as I understand, there can not be done so to automatically push apart the cells to the length of the string (maybe looked bad)

Now it is written like this:

enter image description here

I want to know are there are any libraries, so that the cells length is set to the length of the string written to the cell?

It is necessary that it was like this:

enter image description here

Or maybe there is another approach? For example, manually in Excel to convert all at once so?

I will be grateful for any help, thanks!

Upvotes: 0

Views: 142

Answers (2)

Chabu
Chabu

Reputation: 141

Worksheets("Sheet1").Columns("A:D").AutoFit

Upvotes: 1

Guy Louzon
Guy Louzon

Reputation: 1213

CSV files doesn't have any cell length defintion They are text files, with Comma Seperated Values (CSV ...)

xlsx files however DO hold such a feature They are basically xml zipped

You can either look for a php excel library with a function ready or parse the XML yourself...

XML sturcture is reffred to here Looking for a clear description of Excel's .xlsx XML format

Upvotes: 1

Related Questions