3
$\begingroup$

When I use the form Export["file", list, "Table"] to export a list to Excel, I get columns of lists. I want my Excel sheet to have each list element in a separate column.

For example,

Export["file.xls", {{2, 5}, {5, 7}}, "Table"]

Gives the output

{2,5}
{5,7}

I want those lists above to be split up. How do I do this?

$\endgroup$
2
  • $\begingroup$ Flatten will get rid of the nesting and will give you one column. Not sure how to transpose it. Export["file.xls", Flatten@{{2, 5}, {5, 7}}, "Table"] $\endgroup$
    – brama
    Jul 8, 2014 at 21:17
  • $\begingroup$ There appears to be some confusion about the format of the desired output. Please provide a sample. $\endgroup$
    – brama
    Jul 8, 2014 at 22:27

2 Answers 2

3
$\begingroup$

Correct it to be:

Export["file.xls",{{2,5},{5,7}}]

or more explicitly

Export["file.xls",{{2,5},{5,7}},"XLS"]

"Table" is a generic Table-Format, suitable for a simple Text-Editor, not specially dedicated to Excel

When you leave away the 3rd argument, then the default value is "XLS", and Excel will import it without additional Import-Dialog.

$\endgroup$
1
$\begingroup$

Perhaps

tab = {{2, 5}, {5, 7}};
tab2 = List /@ # & /@ tab  (* or tab2 = Map[List,tab,{-1}] *)
(*  {{{2},{5}},{{5},{7}}} *)
Export["fileA.xls", tab2]

enter image description here

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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