Import of Excel XLS working but not Excel XLSX

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mkweiss
User
Posts: 10

Import of Excel XLS working but not Excel XLSX

Post by mkweiss »

I import .xls files using the $options["headers"] setting overriding any existing headers to match my SQL table field names. This works great for .xls files, but if I save the file to .xlsx it fails with "Invalid field name: 0" and I can see all the field names in the import box named "0 1 2 3 4 5 etc." instead of using the headers I've defined. I can see my data lined up under these numeric field names. What would be causing numeric fields names to show-up only in .xlsx file imports?

I'm running v2024.9

Thanks


arbei
User
Posts: 9384

Post by arbei »

You may post your code for discussion.


mkweiss
User
Posts: 10

Post by mkweiss »

Here's my code to import Excel files:

    $options["headers"] = ["order_num","order_date","list_name","list_select","ordered","mailed","deliver_date","mail_date","mail_code"];
    $options["headerRowNumber"] = 7;
    $options["offset"] = 1;

This works perfect if I import the same file as a .XLS. If I save the file as .XLSX I get:

Processed 2 of 13 records from List of lists F-175.xlsx (success: 0, failure: 2)
Maximum number of errors (1) exceeded
100%
0    1    2    3    4    5    6    7   8
263005	45362	Test Client	$10+ 0-18	10096	4227	45363	45390	LBF175A          
263006	45362	Test Client2	$10+ 0-6	5000	2664	45363	45390	LBF175B

I'm not sure why the PHPMaker is applying 0-8 numeric names to the headers ONLY WITH .XLSX. .XLS imports great with proper field name headers.


mkweiss
User
Posts: 10

Post by mkweiss »

I found the problem. I needed to select all cells and then click Home->Editing->Clear Formats. The Excel .XLSX file imports fine now.


Post Reply