79816699

Date: 2025-11-11 13:36:48
Score: 0.5
Natty:
Report link

A solution has been found. Not quite straight, but clean. Instead of connecting via ODBC, you need to connect via ADODB and the settings for the column header work there.

$conn = new \COM("ADODB.Connection");

$file = 'C:\123.xlsx';
$sheet = 'Sheet1';


$conn->Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$file;Extended Properties=\"Excel 12.0;HDR=No;IMEX=1\"");

$query = "
SELECT
    *
FROM [{$sheet}$]
";

$rs = $conn->Execute($query);
$num_columns = $rs->Fields->Count();

for ($i=0; $i < $num_columns; $i++) {
    $fld[$i] = $rs->Fields($i)->Value();
}

var_dump($fld);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Виктор Виктор