Export data with MFC in Excel and TXT formats

Source: Internet
Author: User

Recently, some things have been done, and the project has reached the final stage. However, this time I did not participate in the function of the control machine, which was written by the supervisor himself. However, I will rewrite all the controls. I also worked with my supervisor on the database. But it's not bad. The supervisor asked me to talk about it in the past. Due to time, he wrote four page control mechanical functions. I wrote query, login, and permissions, operation data. Large and small pages have eight person pages. Some functions are provided by the supervisor for me.

I have gained a lot from this project. As the project is going to exhibit in Germany, a project with many bugs has reached the final stage. Now there are just a few interfaces that haven't been integrated into it. The supervisor is also very busy recently. His child is ill and has undergone major surgery last week. This week is the discharge procedure. The supervisor did not come to the hospital this morning. Wish your child a speedy recovery.

This month is also my test week, and I cannot work overtime to review.

Recently, I am very annoyed that most of the project's affairs have been solved, and I feel that I am not confused. I went to climb Daheishan last week and met a group of tough friends. There will be activities every week to play, climb mountains, and travel. The bad mood of a week has vanished.

This week, I plan to go to the ice Valley. I'm upset about a lot of things, but I am also very happy. Most of my group is very strong, with 150 people and 40 or 50 people in a few. Join them to travel successfully. This evening I wrote a travel note for the thrilling great Montenegro.

This trip found itself a problem. How is the body so bad, the next day mixed body all pain, even walking all pain. The health is getting worse and worse, so I had to go out for a walk.

Go to the topic. If Excel is not installed on your machine, isn't it possible to import it. You can save it as CSV. "," Is used as the interval data.

The exported data is like this.

Date, sensor, Operator
2013-01-06, temperature, Mike
2013-01-16, temperature, users
2013-02-17, pressuere, Jones
2013-03-05, pressure, Jones
2013-04-08, temperature, PTC
2013-04-15, pressure, Mike
2013-04-16, pressure, Mike
2013-04-24, pressure, Mike
Temperature, Mike
2013-05-05, temperature, user3
2013-05-12, temperature, Jones
2013-05-15, pressure, users
2013-05-20, temperature, user2
2013-05-20, temperature, Jones
2013-06-02, pressure, PTC
2013-06-09, temperature, user3
2013-06-17, temperature, user1
2013-06-17, temperature, users

First, put the data in a container.

Struct list_date
{
Cstring date;
Cstring sensor;
Cstring operator;
};

STD: vector <list_date> m_conhistory;

I won't write it here.


Void ccalibrationhistory: onexport ()
{
// True indicates the open dialog box, and false indicates the Save As dialog box.
Cfiledialog Fg (false, _ T ("*. CSV"), null, ofn_hidereadonly | ofn_overwriteprompt,
_ T ("Excel CSV file (*. CSV) | text file (*. TXT | *. TXT | all file (*. *) | *. * | "), null );
If (FG. domodal () = idok)
{
Cstring filename = FG. getpathname ();
Cstdiofile file (filename, cfile: modecreate | cfile: modewrite );
Cstring STR = _ T ("date, sensor, operator \ n ");
File. writestring (STR );
For (STD: vector <list_date>: iterator itor = m_conhistory.begin (); itor! = M_conhistory.end (); itor ++)
{
STR = itor-> date + _ T (",") + itor-> Sensor + _ T (",") + itor-> operator + _ T ("\ n ");
File. writestring (STR );
}
File. Close ();
}
}

Let's take a look at the results. I have saved two formats, Excel. TXT format.

Write it here. I'm busy again. Although it's small, there are still a lot of questions at the end of the project, and I have to continue to improve the code. I learned a lot recently.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.