473,669 Members | 2,523 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(datafil e,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}
Nov 14 '05 #1
7 4257
"SS" <we*******@srst eel.co.uk> wrote in message news:<bv******* ***@news.freedo m2surf.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(datafil e,"%7.3f, %7.3f \n ", t,y);
t = t+Dt;
}
fclose (datafile);
return 0
}

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

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*******@srst eel.co.uk> wrote in message news:<bv******* ***@news.freedo m2surf.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(datafil e,"%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********@yah oo.com) (cb********@wor ldnet.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*******@srst eel.co.uk> wrote in message news:<bv******* ***@news.freedo m2surf.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.program mer.*

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*******@srst eel.co.uk> wrote in message news:<bv******* ***@news.freedo m2surf.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
8131
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: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br>\n"; print STDERR "PERL This is text sent to STDERR<br>\n"; $output="PERL Some output:<br>\n"; for ($i=0; $i<5; $i++) {
3
2786
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"; wstring output;
4
15067
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 this program returns. I'm just missing the stepshere. I know that I can set the Shell command to an integer,but this only returns a 0 to me telling me that it executed, notwhat is being returned to the console by that application. Isthere a way to...
24
2686
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
2062
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 unsigned char #endif
32
2775
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 the same file ? If not then how much variation is allowed ? Is it just a bit more or less white space here and there or could could there be larger differences ? If the output is not deterministic then is it possible that the output of the...
3
2621
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 src=\"" + vars + " />"); output.AddAttribute(HtmlTextWriterAttribute.Src, (string)vars); output.RenderBeginTag(HtmlTextWriterTag.Img);
3
4656
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 <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include "util.h" //Main Loop
5
3320
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. a function syslog (to log output to log file only) 2. a function stdout (to log output to stdout only) 3. a function sslog (to log output to both log and stdout)
2
3372
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 @idUser int OUTPUT,
0
8466
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8896
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8810
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8590
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6211
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2798
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 we have to send another system
2
1790
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.