使用对象路由

I am trying to pass values from my query builder results and to match the dateFrom and dateTo as parts of individual route for every passed result in an table for downloading XLSX file.

Error is that every varibale I write does not exist.

My service

public function getTransaction($dateFrom, $dateTo)
{

    $queryBuilder = $this->getMyRepository()
        ->createQueryBuilder('p')
        ->select('p')
        ->where('p.date >= :from')
        ->andWhere('p.date <= :to')
        ->setParameter('from', $dateFrom->format('Y-m-d H:i:s'))
        ->setParameter('to',   $dateTo->format('Y-m-d H:i:s'))
        ->orderBy('p.id');
        ->getQuery()
        ->getResult();

/**
 * @Route("/export-invoice/{dateFrom}/{dateTo}/{id}", name="export_invoice")
 */
public function downloadInvoice($dateFrom, $dateTo)
{

    $dateOf = $this->get('app')->getTransaction(
        $dateFrom, $dateTo
    );


}

and in my twig

 <a href="{{ path("export_invoice", { dateFrom: dateOf.dateFrom, dateTo: "dateTo", id: "id" }) }}" class="btn btn-sm btn-danger pull-right"><i class="fa fa-fw fa-download"></i> XLSX</a>