Worksheet to table in database

Topics: User Forum
Aug 7, 2009 at 12:04 AM

I am trying to insert a worksheet into a table in my database.

I am under the impression I need to have the worksheet in an array first. Is that correct?

The problem I am having is the array produced includes numerous empty columns

If I use something like the 28iterator example:

 

$cellIterator->setIterateOnlyExistingCells(true);

 

The empty columns are not printed, but then I can not get seem to use toArray() as it gives me an error when I am using the celliterator

 

So any suggestions on how I can get this data into a table without all the extra columns?

Developer
Aug 7, 2009 at 12:25 AM

>> The problem I am having is the array produced includes numerous empty columns

This is a known problem with Excel5 reader in at least PHPExcel 1.6.7. Try to use latest source code where it should be fixed:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Aug 7, 2009 at 12:50 AM

OK-- Thank you, that has gotten rid of all the extra columns

Aug 7, 2009 at 1:13 AM

Any suggestions on how to proceed with getting this into the table?

 

I'd like to be able to make sure the values are inserted into the correct columns.

Developer
Aug 7, 2009 at 7:37 PM

>> Any suggestions on how to proceed with getting this into the table?

I would simply just loop through the rows and columns and read off the values. No need for anything fancy.

In the "PHPExcel Developer Documentation" there is a section "Looping cells" with some examples. Some of this can probably be adjusted to suit your needs.