Question: I'd like to auto-populate an invoice in Excel from data I enter into a lesson roster (`blank_monthly.xlsx`).

![enter image description here](https://i.stack.imgur.com/ZJomS.png)

Here I fill in the lesson cost under the date each time they come for tuition.

In the invoice sheet I would like to start writing a customer's name into a cell, I'd like the rest of the table to populate with information from the current month's customer roster.

Can I use `=vlookup` for this to reference the cell I type the client's name into which then pulls all the other information?

Answer: 
In this line: 

```
$em = $this->getDoctrine()->getManager();

```

`$this` refers to the current class, the `User Entity` that does not have a method called `getDoctrine()`. `$this->getDoctrine()` works in controllers where you extend the `Controller` class a subclass of `ContainerAware` which contains the `getDoctrine()` method.

In other terms, this method works only on objects of class container or its subclasses, like this: `$controller->getDoctrine()->getManager()`.

Besides, you don't want to have an EntityManager inside your entity classes, that's not a good way of doing things. You would better use listners to do such stuffs
I solved this:

```
global $kernel;
$em = $kernel->getContainer()->get('doctrine')->getManager();
$role = $em->getRepository('BackendBundle:user_types')->findOneBy(array(
            'id'    => 10
        ));

```