Maintain order of spreadsheet data

Topics: User Forum
Jan 24, 2011 at 6:15 PM

Hi

How can we maintain the order/sequence of the submitted data?

For instance, say you have the following in a spreadsheet:

Row1 | Row2

1. Fred|Flintstone

2. Barney|Rubble

3. Wilma|Betty

We need the output to match row-by-row order above

Is there any code that can make sure that the order of the rows is the same going in as when extracted?

Thanks

Coordinator
Jan 24, 2011 at 7:56 PM
Edited Jan 24, 2011 at 7:58 PM
scanreg wrote:

How can we maintain the order/sequence of the submitted data?

Excel stores each cell by its coordinates: column and row... e.g. A3, which is column A in row 3; or CF271, which is column CF in row 271. Rows are numbered from 1 to 65536 (for xls files up to Excel 2003) or 1048576 (for xlsx files Excel 2007 and above). Columns are identified by the letters A through Z, followed by AA through AZ, BA through BZ, up to IV (for xls files up to Excel 2003) or XFD (for xlsx files Excel 2007 and above). So does PHPExcel.

However, your sample spreadsheet seems to confuse rows and columns.

  Column A Column B Column C
Row 1 Cell A1 Cell B1 Cell C1
Row 2 Cell A2 Cell B2 Cell C2
Row 3 Cell A3 Cell B3 Cell C3

 scanreg wrote:

We need the output to match row-by-row order above

I'm not sure exactly what you mean by "going in" and "extracted", but is there any reason why you think that PHPExcel might not follow the same cell addressing sequence as Excel itself? The PHPExcel Writers write out each row in turn, and each column within that row in turn. When a program that can read Excel files (such as MS Excel, Open Office Calc, or Gnumeric) reads a file generated by PHPExcel, it will ensure that the cells are displayed in the appropriate rows and columns.

 scanreg wrote:

Is there any code that can make sure that the order of the rows is the same going in as when extracted?

If you're unsure, you can try for yourself.

Alternatively, one of the benefits of Open Source is that you can always see how it works by examining the source code.

Jan 26, 2011 at 3:13 PM

Thanks so much Mark, I'll fool around with it and see what I come up with, thanks again