# Export Table from Mathematica into specific cells Excel

How can I export a table to Excel - to specific cells, e.g. D1-E2?

Background: I want to compare results, and it's easier to have the results on one spreadsheet.

I'm using Mathematica 6.

This is my notebook so far:

ResultsV = Grid[{  {"result1", result1},  {"result2", result2}}]
Export["results.pdf", ResultsV]

This table should appear twice in the spreadsheet, as some parameters differ.

Thanks a lot!

-
I suggest you create an Excel file manually, and then use Import["file.xls", "Rules"] and see what you can learn from it. – Mr.Wizard Jul 25 '12 at 13:30

For example:

(* some data *)
pts = Range[10]^4;
f1 = Interpolation[pts, InterpolationOrder -> 1];
f2 = Interpolation[pts, InterpolationOrder -> 3];
t1 = Join[{{"x", "f1[]"}}, Table[{x, f1@x}, {x, 1.5, 4.5, 1}]];
t2 = Join[{{"x", "f2[]"}}, Table[{x, f2@x}, {x, 1.5, 4.5, 1}]];
data = Join @@@ Transpose@{t1, t2};

(* Transformation from Excel "A1" notation to indexes *)
at = {FromDigits@ToExpression@Flatten[StringCases[Characters[#], _?DigitQ], 1],
FromDigits[Flatten[ToCharacterCode /@ StringCases[Characters[#], _?UpperCaseQ] -
First@ToCharacterCode["A"] + 1, 2], Length@CharacterRange["A", "Z"]]} &;

(* Generation of a sparse array with the required block positioning *)
sp[data_List, pos_String] := SparseArray[
Flatten@MapIndexed[#2 + at@pos - 1 -> #1 &, data, {2}],
Automatic, ""];

(* export the data to Excel*)
Export["c:\\test2.xls", sp[data, "B3"]]

-
How does this show filling e.g. D1-E2? – Mr.Wizard Jul 26 '12 at 2:07
@Mr.Wizard In a previous incarnation of this answer (you may look at it in the edit history) I posted a way to convert from "excel coordinates" to indexes. As I didn't get a reply from the OP, I am trying now to show him a different thing. Sorry, but if it isn't this one, I am unable to understand what is he looking for. – Dr. belisarius Jul 26 '12 at 2:30
I believe the idea is to do Export["file.xls", data] and have certain columns filled in; no time now to talk about it though, sorry. – Mr.Wizard Jul 26 '12 at 2:32
@Mr.Wizard did it. Not sure if this is what the OP wanted, but anyway .. – Dr. belisarius Jul 26 '12 at 2:58
I'm new in Mathematica - I still do not understand in detail what you did, belisarius (nevertheless, Thanks, I'll work it out). It may be not exactly what I am looking for: I run my computations for different cases and at the end of the programm, I export the data. Running the file twice (for the second case, eg), I'd like to write the data into the already existing xls file that contains the results of the first case. – Stefanie Schubert Jul 29 '12 at 21:44