I'm supposed to put together an Excel spreadsheet. I've always been the
type of person who would rather write a script than use Excel, but in
this case I need to share data with people who use Excel.
I'm wondering if it's possible to get Ruby to create files that Excel can
read? I suspect that I should be able to use the CSV module for doing
this. Do I need to create a seperate header file or can the header be
placed at the top of the CSV file? (I don't have Excel, so I can't test
this)
So for example, I need to make a spredsheet of students (columns) and
quiz/homework/test scores, something like:
How would I set this up so that the CSV file written by Ruby can be read
by Excel?
I suspect that at the first line of the file I would need to be:
desc, student1, student2, student3, student4
correct? Then I would use CSV to write out the data which I would
probably store in hashes.
How would I set this up so that the CSV file written by Ruby can be read
by Excel?
What you have here is perfect. Excel is pretty flexible - you can delimit
by commas, tabs, spaces, whatever you like. The above is definitely more
easily readable than comma delimitation, but I think you'll have yourself
an extra mouseclick or two if you do use commas.
I'm supposed to put together an Excel spreadsheet. I've always been the
type of person who would rather write a script than use Excel, but in
this case I need to share data with people who use Excel.
I'm wondering if it's possible to get Ruby to create files that Excel can
read? I suspect that I should be able to use the CSV module for doing
this. Do I need to create a seperate header file or can the header be
placed at the top of the CSV file? (I don't have Excel, so I can't test
this)
So for example, I need to make a spredsheet of students (columns) and
quiz/homework/test scores, something like:
How would I set this up so that the CSV file written by Ruby can be read
by Excel?
I suspect that at the first line of the file I would need to be:
desc, student1, student2, student3, student4
correct? Then I would use CSV to write out the data which I would
probably store in hashes.
I'm wondering if it's possible to get Ruby to create files that Excel can
read? I suspect that I should be able to use the CSV module for doing
this. Do I need to create a seperate header file or can the header be
placed at the top of the CSV file? (I don't have Excel, so I can't test
this)
No need for extra modules if you don't need formulas or visual styling.
CSV headers will do. Tab separated fields will work regardless of
locale setting.
If you rename your CSV file as .XLS and double-click it in the
explorer, Excel will open it just like any other spreadsheet.
Also, if you copy tab-delimited CSV data to the clipboard, Excel will
paste it just as well.
I have had some success generating html files and importing these into Excel. The data is held in a table. One advantage of this over CVS is the formatting embodied in the html is also imported into Excel.
Dave.
···
On 5 Apr 2005, at 21:54, Phil Tomson wrote:
I'm supposed to put together an Excel spreadsheet. I've always been the
type of person who would rather write a script than use Excel, but in
this case I need to share data with people who use Excel.
>
> I'm supposed to put together an Excel spreadsheet. I've always been
> the
> type of person who would rather write a script than use Excel, but in
> this case I need to share data with people who use Excel.
<snip>
I have had some success generating html files and importing these into
Excel. The data is held in a table. One advantage of this over CVS is
the formatting embodied in the html is also imported into Excel.
Excel as source code control?
···
On Apr 6, 2005 6:13 PM, Dave Baldwin <dave.baldwin@3dlabs.com> wrote:
And if you dont want to go the OLE route, or want to do this on Mac or
Linux, see http://jakarta.apache.org/poi/poi-ruby.html , which will let
you create real Excel files (not CVS or HTML) .