diff --git a/src/@report_data/report_data.m b/src/@report_data/report_data.m
index 4f9f4a21563e23e6806b0c4da1962d691dfc8372..84683d06aacf325ca8eebde53e10faf54d84bd68 100644
--- a/src/@report_data/report_data.m
+++ b/src/@report_data/report_data.m
@@ -26,6 +26,9 @@ classdef report_data < handle
         tablePrecision = ''
         zeroTol = 1e-6
     end
+    properties
+        column_names = ''
+    end
     methods
         function o = report_data(varargin)
             %function o = report_data(varargin)
diff --git a/src/@report_table/report_table.m b/src/@report_table/report_table.m
index d7418e02017e071f11541929ba32fc08dbf7255b..adf24a465ad992418cd1f31a7951146d1a4e8768 100644
--- a/src/@report_table/report_table.m
+++ b/src/@report_table/report_table.m
@@ -22,11 +22,10 @@ classdef report_table < handle
     end
     properties (Access = private)
         series = {}
-        table_data = {}
+        table_data = {}               % The table data
         % Not documented
         preamble = {''}
         afterward = {''}
-        column_names = ''
     end
     properties (SetAccess = private)
         tableDirName = 'tmpRepDir'    % The name of the folder in which to store this table. Default: tmpRepDir.
diff --git a/src/@report_table/writeTableFile.m b/src/@report_table/writeTableFile.m
index 144f8169144d0fc348b341b80054c80a5bf1a11a..f1039173f176293fe2c17bf7a3555abc9b9f5836 100644
--- a/src/@report_table/writeTableFile.m
+++ b/src/@report_table/writeTableFile.m
@@ -39,7 +39,9 @@ if ne == 0 && ~is_data_table
     warning('@report_table.write: no series to plot, returning');
     return
 end
-
+if is_data_table
+    ne = size(o.table_data{1}.data,2);
+end
 if exist([rep_dir '/' o.tableDirName], 'dir') ~= 7
     mkdir([rep_dir '/' o.tableDirName]);
 end
@@ -177,8 +179,13 @@ else
     if o.showVlines
         fprintf(fid, '|');
     end
-    for i = 1:length(o.column_names)
-        if isempty(o.column_names{i})
+    if ~isempty(o.table_data{1}.column_names) && ne ~= length(o.table_data{1}.column_names)
+        error(['@report_table.writeTableFile: when writing a data table and passing the ' ...
+            '`column_names` option, it must have the same number of elements as the ' ...
+            'number of columns in the data']);
+    end
+    for i = 1:ne
+        if isempty(o.table_data{1}.column_names) ||isempty(o.table_data{1}.column_names{i})
             fprintf(fid, 'l');
         else
             fprintf(fid, 'r');
@@ -216,14 +223,16 @@ if ~is_data_table
         csvseries.save(strrep(o.tableName, '.tex', ''), 'csv');
     end
 else
-    fprintf(fid, '%%\n');
-    fprintf(fid, '\\hline%%\n');
-    fprintf(fid, '%%\n');
-    for i = 1:length(o.column_names)
-        if ~isempty(o.column_names{i})
-            fprintf(fid, '%s', o.column_names{i});
+    if ~isempty(o.table_data{1}.column_names)
+        fprintf(fid, '%%\n');
+        fprintf(fid, '\\hline%%\n');
+        fprintf(fid, '%%\n');
+    end
+    for i = 1:ne
+        if ~isempty(o.table_data{1}.column_names) && ~isempty(o.table_data{1}.column_names{i})
+            fprintf(fid, '%s', o.table_data{1}.column_names{i});
         end
-        if i ~= length(o.column_names)
+        if i ~= ne
             fprintf(fid, ' & ');
         end
     end