Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After performing some calculations with excel sheets I end with a tridimensional matrix a to be export to a .xlsx format and a vector q that contains the name of all the sheets (so $Length[q] = Length[a]$). In the documentation the usual way to export this named excel data is to do something like

Export["file name.xlsx", q[[1]] -> a[[1]], ..., q[[n]] -> a[[n]]] ]

But since the $Length[a]]$ is variable I do not know an automatic way to do that. I tried something like

q -> a

But Mathematica can't process in this way.

How can I do that?


share|improve this question
You say the usual way to export this named and then the command says Import? Is this a typo? – Nasser Jan 27 '14 at 22:38
Yes, thanks, @Nasser. – Zhozer Jan 28 '14 at 1:18
up vote 7 down vote accepted
a = {{{1}}, {{2}}};
q = {"one", "two"};
Export["c:\\test.xlsx", Rule @@@ Transpose@{q, a}]

Mathematica graphics

share|improve this answer
Fantastic, thanks, @belisarius. I was trying something more complicate. I need to use more the rule method. ^^ – Zhozer Jan 28 '14 at 22:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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