1
$\begingroup$

Please suggest how to export multiple tables in a single excel file. I am trying to use the code given below:

d1 = {{1, 26.00}, {0.8, 35.43}, {0.6, 33.40}, {0.4, 31.11}, {0, 56.67}};
d2 = {{1, 45.58}, {0.8, 50.16}, {0.6, 56.18}, {0.4, 57.03}, {0, 33.17}};
d3 = {{1, 10.23}, {0.8, 9.13}, {0.6, 6.88}, {0.4, 10.11}, {0, 5.86}};
d11 = TableForm[d1]; 
d22 = TableForm[d2]; 
d33 = TableForm[d3];
Export["d1diles.xls", {d11, d22, d33}, "XLS"]

Also, the 1st column is common in all tables, so I just want it to appear in the spreadsheet one time.

$\endgroup$
6
  • 3
    $\begingroup$ Export["d1diles.xls", {d1, d2, d3}, "XLS"] You want to export the lists. TableForm is for display puposes. $\endgroup$ – LouisB Dec 5 '20 at 7:06
  • $\begingroup$ @ LouisB , I want to export as an excel file, after that I want to plot in other plotting software e.g Origin $\endgroup$ – Gopal Verma Dec 5 '20 at 8:10
  • 3
    $\begingroup$ To combine the 3 tables into one and export it, use Export["d1diles.xls", Transpose@ Flatten[Transpose /@ {d1, d2, d3}, 1][[{1, 2, 4, 6}]], "XLS"] $\endgroup$ – LouisB Dec 5 '20 at 8:25
  • 2
    $\begingroup$ I would look into the plotting/visualizations of Wolfram as an alternative to Origin. Especially when you need to do explorative work, that is iterating between the diagrams and the data (both "raw" and "filtered") $\endgroup$ – FredrikD Dec 5 '20 at 8:29
  • 1
    $\begingroup$ Export["d1diles.xls", Join[{#[[1, 1]]}, #[[All, 2]]] & /@ GatherBy[Flatten[{d1, d2, d3}, 1], First] // Sort] $\endgroup$ – Bob Hanlon Dec 5 '20 at 15:56
1
$\begingroup$

According to MMA help, one can export multiple tables as pages in Excel file:

Export["file.xlsx", 
       "Sheets" -> {"Experiment 1" -> d1, 
                    "Experiment 2" -> d2, 
                    "Experiment 3" -> d3}, "Rules"]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.