Void Csmyc: : OnClickedButtonBc ()
{
//TODO: add the control notification handler code
WORD sYear, sMonth, sDay sHour, sMinute, sSecond;
SYSTEMTIME CurTime;/////define SYSTEMTIME object of a class
GetLocalTime (& amp; CurTime);////get the local time
SYear=CurTime. WYear;////for years
SMonth=CurTime. WMonth;//get month
SDay=CurTime. WDay;
SHour=CurTime. WHour;
SMinute=CurTime. WMinute;
SSecond=CurTime. WSecond;
Cstrings sFileName;
SFileName. The Format (_T (" % d on % d % d % d % d % d seconds. XLS "),
SYear, sMonth sDay, sHour sMinute, sSecond);
CFileDialog DLG (FALSE, ". XLS ", sFileName, OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY, "(*. XLS) | *. XLS | |", this);
DLG. M_ofn. LpstrTitle=_T (" save file ");
If (DLG) DoModal ()==IDOK)
{
//save
Buff1 cstrings buff0 [1024], [1024].
Cstrings fileName=DLG. GetPathName ();
CFile file (fileName, CFile: : modeCreate | CFile: : modeReadWrite | CFile: : shareExclusive);
File. The Write (" prediction of failure mode \ t \ n ", 35).
int i=0;
int j=0;
J=m_ycjg_list GetItemCount ();
If (j & gt; 0)
{
for (i=0; I{
Buff0 [I]=m_ycjg_list. GetItemText (I, 0).
Buff1 [I]=m_ycjg_list. GetItemText (I, 1);
Cstrings MSG.
MSG. The Format (_T (" % s \ t % s \ n "), buff0 [I], buff1 [I]);
File. The Write (MSG, MSG. GetLength ());
}
}
File. The Close ();
}
return;
}
List data is like this:
Output to excel goes like this:
Update -- -- -- -- -- - -- -- -- -- -- -- -- --
Ok, I now to solve this problem, now the last remaining problem, export XLS file open always tip file format and extensions, but on the display is normal, is there any way to get rid of the warning is opened?
Only after the first time open the hint, open the no
CodePudding user response:
Baidu search relevant keywords,CodePudding user response:
That's because you written in CFile file directly, is actually a TXT file, is not at all but the extension is Excel file format. XLSSo this is equivalent to use Excel you open a TXT, and Excel cell is with the \ t delimited, so after forced open display is normal
CodePudding user response:
http://blog.sina.com.cn/s/blog_6c3d32da0100u9ep.htmlCodePudding user response:
File extension is modified to CSVCodePudding user response:
Can create a new Excel file, and then to write data into the ~ there should be no problem