MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: exporting to multiple sheets in XLS format

  • To: mathgroup at
  • Subject: [mg87511] Re: exporting to multiple sheets in XLS format
  • From: Januk <ggroup at>
  • Date: Sat, 12 Apr 2008 06:56:05 -0400 (EDT)
  • References: <ftkb8g$ab0$>

In version 6.0.2 (I don't know about earlier), you can fake the
appending of new sheets onto an old workbook.  Unfortunately this
method destroys any formatting or formulas you may have in your
original file, but hopefully it will give you a starting point.
Please post if you find/create a better solution.

------- Begin Example -------
XLAppend[oldfile_, newfile_, newdata_] :=
 Module[{sheets, olddata, completedata},

  sheets = Import[oldfile, "Sheets"];
  olddata = {#, Import[oldfile, {"Sheets", #}]} & /@ sheets;

  completedata = Join[olddata, newdata];
  Export[newfile, Rule @@@ completedata]

tmp = RandomReal[{1,10}, {5,10}];

XLAppend["Old File.xls", "New File.xls", {{"Random Numbers", tmp}}]

------- End Example --------

Hope that helps,

On Apr 10, 2:14 am, "Russo, Peter (10170)" < at>
> Is there a way to export to multiple worksheets in excel XLS format=3F
> When importing, you can choose which sheet to import from, for example:
> Import["sample.xls",{"Data",2}]
> will import the data fields from worksheet 2.
> However, is there a way to do the same sort of thing with export=3F
> Or even better, write to many worksheets all at once (in the same XLS
> object ) or the ability to append worksheets to already created XLS
> document.

  • Prev by Date: Re: Re: Documentation - what is the big secret?
  • Next by Date: Re: Re: PolarPlot
  • Previous by thread: Re: exporting to multiple sheets in XLS format
  • Next by thread: Directory of Mathematica Add-Ons