473,395 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How export data from Visual C++ to CSV?

14
Hi!

Can someone explain me the steps to follow to export the data originated in a dialog based visual c++ (version 6.0) program to a CSV file?

I've tried somthing like this:
Expand|Select|Wrap|Line Numbers
  1. void CSizeDistributionDlg::OnSave() 
  2. {
  3.     // TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
  4.     const char *filename = "C:\Documents and Settings\X\Desktop\trycsv.csv";
  5.    FILE *Archi;
  6.    Archi = fopen(filename,"w");
  7.    if (Archi==0)
  8.       fprintf(stderr, "Fallo abriendo... %s para escribir\n",filename);      
  9.    fprintf(Archi,"Hola mundo\n");
  10.    fprintf(Archi,"Hola,Mundo\n");//etc...
  11.    fclose(Archi); 
  12. }
  13.  
  14. void CSizeDistributionDlg::OnOpen() 
  15. {
  16.     // TODO: Code für die Behandlungsroutine der Steuerelement-Benachrichtigung hier einfügen
  17.     char linea[100], cadena[100];
  18.    const char *filename = "C:\Documents and Settings\X\Desktop\trycsv.csv";
  19.    FILE *Archi;
  20.    Archi = fopen(filename,"r");
  21.    if (Archi==0)
  22.       fprintf(stderr,"Fallo al abrir %s \n",filename);
  23.  
  24.    for(int j=0;;j++){//total lineas
  25.       if (feof(Archi)) break;
  26.       for (int i=0;i<100;i++) {//caracteres          
  27.          linea[i]=fgetc(Archi);
  28.          if (linea[i]=='\n') break;
  29.          if (feof(Archi)) break;
  30.       }
  31.       linea[i] = '\n';   //fin d datos de las celdas   
  32.       strcpy(cadena, linea); //ultima cadena
  33.    }   
  34.    fclose(Archi);    
  35. }
  36.  
  37.  

but it gives me errors when running it (Debug assertion failed)

Should I include something else, like headers or classes...?? I'm quite new in programming and I have not a global vision of this....

The reason I need to export to CSV is to open then with excel...

Thank you in advance!!
May 25 '07 #1
1 5684
weaknessforcats
9,208 Expert Mod 8TB
Yes, there are requirements for a .csv file in terms of headers and formatting.

You should search MSDN for this.

Just having a .csv in the file name is not enough.
May 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: gdubois | last post by:
Hi everybody! I am currently working with C# and MSDE. Is there an easy way to export all the data from MSDE in case something crashes? Also, is it possible to export the database structure? ...
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
0
by: Max Mayer | last post by:
Hello everybody, I have implemented a windows form in C# .NET to export data from a listbox to Excel. I work on a Windows XP machine with Office 97 and .NET framework 1.1 SDK installed. I use...
0
by: Max Mayer | last post by:
Hello everybody, I have implemented a windows form in C# .NET to export data from a listbox to Excel. I work on a Windows XP machine with Office 97 and .NET framework 1.1 SDK installed. I use...
11
by: Dr. Zharkov | last post by:
We want to export myArrayVB (2000, 2) of VB .NET 2003 in myArrayVó of VC++ .NET 2003 on scheme "component - client". But there is an error. For development of a component in VB .NET 2003 we...
4
by: Agnes | last post by:
I can export the data to excel, but it is really really slow. need 5-6 mins to export 30 fields (a hundred records) . for my old vfp application, less than 3 minutes. for 500-800 records. Does any...
4
by: Steven T. Hatton | last post by:
<quote url="http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=53&rl=1"> exported Templates Last updated Sep 6, 2006. exported Templates The separate compilation model enables...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
5
by: bhodgins | last post by:
Hi, I am new on here, and had a newbie question that I am stumped with. I am not new to access, but am new to VB. I am trying to export BLOBs from a field called photo to external jpeg files. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.