tags:

views:

70

answers:

3

Is there a way to output to an excel file but to assign what you're outputting to a specific cell in the excel file?

For example have an array be cell x 1-50 or something like this.

A: 

You can output an html formatted table to a file with an xls extension. When loading it, Excel will convert it to a spreadsheet. Sample:

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
tibur
Do i just add this to my code? So what would an output look like? say i wanted the string "the" in row two cell 1.
Alec
@Alec: No, that's what the *output* of your code would have to look like.
Billy ONeal
+1  A: 

There are some C++ libraries for that. An example of a free one is xlsstream and a commercial one would be LibXL. Google is your friend to find more.

Tronic
It should be noted that some libraries (such as xlsstream) require Excel to be installed on the computer where the program will be run. This is because such a library actually does its work through the COM interface that Excel provides. This may or may not be a problem depending on the purpose of the program. On the other hand, ones like LibXL do not require Excel, so presumably they must be manipulating the files directly.
TheUndeadFish
@TheUndeadFish That's a good point, thanks for clarifying.
Tronic
A: 

You can output data in as CSV and excel will read it just fine:

row 1 cell 1, row 1 cell 2
row 2 cell 1, row 2 cell 2
Martin York
So, put this before what i am trying to output?
Alec