How can I construct a table view with columns passed as a parameter? I have a content type, referenced by multiple subsequent content types and at some point I made a spreadsheet with all that data. My new assignment is to display a view like that and then export it to Excel, but before that let the user choose which columns appear in the table. I'm also going to need to be able to display exposed filters for all the chosen columns and save the columns and the filters as a report template.

Is it possible to do all that using Views or perhaps create it from scratch as a new entity?

I've been trying to do that in Views and I've hit a few walls. I thought about creating a bunch of PHP fields for all possible columns and check if they should be displayed based on the list of columns to display. Displaying data that way worked, but I can't put filters on PHP fields so I pretty much can't use them here. 

After that I tried simply displaying all the columns initially and then in the "modify output" part of the fields display an empty string if that column is not on the list of columns to display (this way I could simply hide the empty columns). Only to realize you can't put PHP code anywhere in the view field settings. 

Haven't managed to get that far but I think you can't simply display a node and x referencing nodes in one table row. 
How it works in my db is that there's a "Examination" content type, which has different types. Multiple examinations might reference the same node so I'd have to find a way to display that node and all referencing examination types in the same row. Assuming each type can occur once.

^ This part might deserve it's own question though.

To put it shortly: I need to populate table view columns based on a list of columns while still being able to expose full filters to each column
What you'll want to do is create a new display (using the table style) on the fly and then use that display to render the output.

If you take a look at views exports, you can get an idea of how columns are added to new displays:

From commerce_cart.views_default.inc:

$handler = $view-&gt;new_display('default', 'Defaults', 'default');
$handler-&gt;display-&gt;display_options['title'] = 'Shopping cart';
$handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
$handler-&gt;display-&gt;display_options['style_options']['columns'] = array(
  'quantity' =&gt; 'quantity',
  'commerce_display_path' =&gt; 'commerce_display_path',
  'line_item_title' =&gt; 'line_item_title',
  'commerce_total' =&gt; 'commerce_total',
);

// Ignoring relationships...

$handler-&gt;display-&gt;display_options['style_options']['info'] = array(
  'quantity' =&gt; array(
    'sortable' =&gt; 0,
    'default_sort_order' =&gt; 'asc',
      'align' =&gt; '',
    'separator' =&gt; '',
  ),
  'commerce_display_path' =&gt; array(
    'sortable' =&gt; 0,
    'default_sort_order' =&gt; 'asc',
    'align' =&gt; '',
    'separator' =&gt; '',
  ),
  'line_item_title' =&gt; array(
    'align' =&gt; '',
    'separator' =&gt; '',
  ),
  'commerce_total' =&gt; array(
    'sortable' =&gt; 0,
    'default_sort_order' =&gt; 'asc',
    'align' =&gt; 'views-align-right',
    'separator' =&gt; '',
  ),
);

  /* Field: Commerce Line Item: Quantity */
  $handler-&gt;display-&gt;display_options['fields']['quantity']['id'] = 'quantity';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['table'] = 'commerce_line_item';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['field'] = 'quantity';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['relationship'] = 'commerce_line_items_line_item_id';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['label'] = '';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['precision'] = '0';
  $handler-&gt;display-&gt;display_options['fields']['quantity']['suffix'] = ' × ';
  /* Field: Commerce Line item: Display path */
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['id'] = 'commerce_display_path';
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['table'] = 'field_data_commerce_display_path';
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['field'] = 'commerce_display_path';
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['relationship'] = 'commerce_line_items_line_item_id';
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['label'] = '';
  $handler-&gt;display-&gt;display_options['fields']['commerce_display_path']['exclude'] = TRUE;


And so on. Then, just save the view (views_save_view()) and render the output. Commerce has a function called commerce_embed_view() that shows how to make this happen. This is slightly modified, though:

// You can get the ID after you save it.
$view-&gt;set_display($display_id);

// Set the specific arguments passed in. Optional.
$view-&gt;set_arguments($arguments);

// Prepare and execute the View query.
$view-&gt;pre_execute();
$view-&gt;execute();

// Return the rendered View.
return $view-&gt;render();