MathGroup Archive 2007

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

Search the Archive

Re: Exporting TableHeadings to Excel

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76993] Re: Exporting TableHeadings to Excel
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 31 May 2007 03:28:11 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f3jh42$dd6$1@smc.vnet.net>

Dean Williams wrote:
> Using the example below, I am trying to export the TableHeadings to
> accompany the data into Excel.
> 
> However, when I open Excel, the TableHeadings are lost.
> 
> Is there a way to export the TableHeadings and data together?
> 
> Regards
> 
> Dean
> 
> 
> data = {{"Item1", 1, 2}, {"Item2", 3, 4}}
> 
> aa = TableForm[data,
>   TableHeadings -> {None, {"Item", "Heading1", "Heading2"}}]
> 
> Export["testxls.xls", aa]

Dean,

TableForm is a wrapper function, that is a function that modifies the 
way an expression is displayed but not the expression itself. So, when 
you call Export, although aa contains the TableForm command, TableForm 
is removed first and only data is passed as actual argument to Export.

You can use Prepend to get the desired result, as in

aa = Prepend[data, {"Item", "Heading1", "Heading2"}]

Regards,
Jean-Marc


  • Prev by Date: Re: Famous Mathematica 5.0 not working with Mathematica 6?
  • Next by Date: Re: The Requested Evaluator ...
  • Previous by thread: Re: Exporting TableHeadings to Excel
  • Next by thread: Another strange cursor behavior in 6.0