473,511 Members | 15,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

output to *.xls

SS
I'd like, instead of outputting to a *.csv file to output the results from
the code below to an excel sheet.
I changed the datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells
all i get is a coulmn of pairs of results seperated by a comma - i want two
columns of data
can anyone help...
================================================== ======================

# include <stdio.h>
main ()
{
FILE *datafile;
datafile = fopen ("a:\\lab1-1-1.csv","w");
float Dt = 0.01;
float u = 1;
float Tmax = 2;
float t = 0 , e = 0, y1 = 0, y = 0;
float J = 0.02;
float k = 10;
float B = 0.5;
while (t<=Tmax)
{
e = u - y ;
y1 = y1 +(k* Dt*e);
y = y+Dt/J*(k*y1-B*y);
printf("%7.3f %7.3f \n",t,y);
fprintf(datafile,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}
Nov 14 '05 #1
7 4249
"SS" <we*******@srsteel.co.uk> wrote in message news:<bv**********@news.freedom2surf.net>...
I'd like, instead of outputting to a *.csv file to output the results from
the code below to an excel sheet.
I changed the datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells
all i get is a coulmn of pairs of results seperated by a comma - i want two
columns of data
can anyone help...
================================================== ======================

# include <stdio.h>
main ()
{
FILE *datafile;
datafile = fopen ("a:\\lab1-1-1.csv","w");
float Dt = 0.01;
float u = 1;
float Tmax = 2;
float t = 0 , e = 0, y1 = 0, y = 0;
float J = 0.02;
float k = 10;
float B = 0.5;
while (t<=Tmax)
{
e = u - y ;
y1 = y1 +(k* Dt*e);
y = y+Dt/J*(k*y1-B*y);
printf("%7.3f %7.3f \n",t,y);
fprintf(datafile,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}

This is offtopic, go to comp.os.ms-windows.programmer.*

and they will tell you that the Excel file format has never been
released by Microsoft. You must reverse engineer it, or find some
code that already has.
Nov 14 '05 #2
"SS" <we*******@srsteel.co.uk> wrote in message news:<bv**********@news.freedom2surf.net>...

Topicality issues aside, you can find the Excel file format documented
here:

http://www.wotsit.org/search.asp?page=2&s=database

Start by getting familiar with the Windows structured storage API
though. You'll need it.
Nov 14 '05 #3
SS wrote:

I'd like, instead of outputting to a *.csv file to output the
results from the code below to an excel sheet. I changed the
datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells all i get is a coulmn of
pairs of results seperated by a comma - i want two columns of
data can anyone help...
.... snip ...
printf("%7.3f %7.3f \n",t,y);
fprintf(datafile,"%7.3f, %7.3f \n ", t,y);


Tou have output text. For anything else, you first need to define
the output format required. What is a .csv file. What is an
excel sheet. What is a .xls file. What is a cell. Enquiring
minds want to know. Be detailed and specific. All things that
are not defined in the C standard are not known here on c.l.c.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #4
Rob Thorpe wrote:

"SS" <we*******@srsteel.co.uk> wrote in message news:<bv**********@news.freedom2surf.net>...
I'd like, instead of outputting to a *.csv file to output the results from
the code below to an excel sheet.
This is offtopic, go to comp.os.ms-windows.programmer.*

and they will tell you that the Excel file format has never been
released by Microsoft. You must reverse engineer it, or find some
code that already has.

Or use the work already done by others. This (and most other file format
questions) can be resolved at

http://www.wotsit.org/

Brian Rodenborn
Nov 14 '05 #5
"SS" <we*******@srsteel.co.uk> wrote in message news:<bv**********@news.freedom2surf.net>...
I'd like, instead of outputting to a *.csv file to output the results from
the code below to an excel sheet.
I changed the datafile extension to read *.xls and it outputs the data but
does not put it into seperate cells
all i get is a coulmn of pairs of results seperated by a comma - i want two
columns of data
can anyone help...


You either have to learn about Excel formats and get more involved in
windows specifics (making a win32 group more appropriate) or stick
with .csv as a text file

You can get quite are with a csv if you are willing to forego
formatting etc.

Something simple like:

20
10
=a1+a2,5,=a3*b3

works ok. You could also explore other text format, xml, for
instance that Excel or some other spreadsheet may be able to deal with

Then your c program issues will pertain only to text manipulation and
questions of standards and correctness.
Nov 14 '05 #6
On Thu, 05 Feb 2004 06:54:07 +0000, SS wrote:
I'd like, instead of outputting to a *.csv file to output the results from [write excel from c] can anyone help...


Yes.

Step 1 for all alternatives: Know that the filename means nothing to C and
that _you_ have to make a program save in a specific format.

Alt 1: leave the program unchanged, import the file into some spreadsheet
that can save to excel format, save.
Alt 2: Pay Microsoft. Get specification or library or something you can
use. Move on to ms specific newsgroup.
Alt 3: Reverse engineer file format.
Alt 4: Locate specification or library or something you can use from
someone that has already reverse engineered the file format.

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up

Nov 14 '05 #7
SS
I'll stick to *.csv.
SS
Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8120
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
2770
by: edgekaos | last post by:
Is method 2 valid? Method 1: wstring input = L"STRING"; wstring output = input; transform(output.begin(), output.end(), output.begin(), towupper); Method 2: wstring input = L"STRING";...
4
15037
by: Kevin Mansel via .NET 247 | last post by:
Ok, basically this is my problem. I'm building a console app tocall a dos program. So i'm using the Shell command to call theprogram, now depending on what happens, I want to read theoutput that...
24
2665
by: kalamantina | last post by:
#include "stdafx.h" #include <stdio.h> #define output( x ) printf( #x "\r\n" );fflush( stdout ) class CMyBase { public: CMyBase() { output( CMyBase() ); f(*this);
0
2051
by: newbie | last post by:
i'm a newbie of c language. can anyone help me to implement the code so that I can get the ciphertext from the output. thanks. #ifndef _3DES_H #define _3DES_H #ifndef uint8 #define uint8 ...
32
2737
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
3
2613
by: MatsL | last post by:
Hi, This is seriously driving me crazy, could anyone explain to me why neither of these doesn't produce XHTML compliant output (it is being called in Render() btw): output.WriteLine("<img...
3
4641
by: undshan | last post by:
I am writing a code that needs to open a file, create an output file, run through my function, prints the results to the output file, and closes them within a loop. Here is my code: #include...
5
3313
by: amit.uttam | last post by:
Hey everyone, I've recently jumped big time into python and I'm working on a software program for testing automation. I had a question about proper logging of output. What I would like is: 1....
2
3358
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables ...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.