How can I construct a table view with columns passed as a parameter?
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();