MFC in C + + creates an Excel table and adds data to an Excel table method

Source: Internet
Author: User

Method 1:

CStdioFile File;

CString str;
File.Open ("D\\1.xls", cfile::modecreate| Cfile::modereadwrite)///If the file does not exist beforehand, it needs to be cfile::modecreate, otherwise it will not need

Keywords: location, processing type, event start time, event end time, processing person, processing time, escalation type, event recording name, event picture name, notes
Str. Format ("%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c", "Location", 9, "Processing Type", 9, "event Start Time", 9, "event End Time", 9, "handler", 9, "Processing Time", 9, "escalation type" ", 9," event recording name ", 9," event picture name ", 9," remark ", 13);

File.writestring (str);

File.close ();

Add a row of data

Str. Format ("%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c", strcamname,9,phandleeventname[sjlx],9,row2,9,row3,9,row7,9, row5,9,streventname,9, str_linkvideopath,9, str_linkpicpath,9,row8,13);

File.writestring (str);

Method 2:

CDatabase database;

CString sSQL;

Ssql.format ("driver={%s};D sn="; Firstrowhasnames=1; Readonly=false; Create_db=\ "%s\";D bq=%s ", Sdriver, Sexcelfile, sexcelfile);
//CREATE DATABASE (i.e. Excel tabular file)
if ( Database. OpenEx (Ssql,cdatabase::noodbcdialog))
{
//CREATE TABLE structure =
sSQL = "CREATE Table Backup Event List (location text,   processing type text,   event start time text,   event end time text,   processing person text, processing time text, escalation type text, event video Name text, event picture Name text, notes text)";
database. ExecuteSQL (sSQL);

Ssql.format ("INSERT into Backup Event list (location, processing type, event start time, event end time, processing person, processing time, escalation type, event recording name, event picture name, remarks) VALUES ('%s ' , '%s ', '%s ', '%s ', '%s ', '%s ', '%s ', '%s ', '%s ', '%s '),
Strcamname,phandleeventname[sjlx],row2,row3,row7, Row5,streventname, Str_linkvideopath, STR_LINKPICPATH,ROW8);
Database. ExecuteSQL (sSQL);

Close the database

Database. Close ();

}

MFC in C + + creates an Excel table and adds data to an Excel table method

Related Article

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.