请问 怎么在VC++中将数据生成WORD文件
请教 如何在VC++中将数据生成WORD文件
怎么样才能在自己 的 程序中生成自己程序中收集到的数据并生成WORD格式的文件。谢谢 大家了
------解决方案--------------------
什么格式的数据?
最简单的情况就保存为文本文件,后缀名为doc即可
------解决方案--------------------
http://www.vckbase.com/document/viewdoc/?id=1174
这篇文章就可以解决
------解决方案--------------------
顶了再看。
------解决方案--------------------
后面扩展名为.doc就可以啊
------解决方案--------------------
事例代码:
void CDemoDoc::WriteToLog(CString strInfo,CString strPath)
{
try
{
CString tmpStr;
tmpStr.Empty();
CTime mTime;
mTime=CTime::GetCurrentTime();
tmpStr.Format(_T( "%04d-%02d-%02d %02d:%02d:%02d %s \r\n "),mTime.GetYear(),
mTime.GetMonth(),mTime.GetDay(),mTime.GetHour(),mTime.GetMinute(),mTime.GetSecond(),strInfo);
int nLen=tmpStr.GetLength();
TCHAR* tBuf=tmpStr.GetBuffer(nLen);
CFile file;
if(file.Open(strPath,CFile::modeRead,NULL))
{
file.Close();
if(file.Open(strPath,CFile::modeWrite,NULL))
{
file.SeekToEnd();
file.Write(tBuf,nLen*sizeof(TCHAR));
file.Close();
}
}
else
{
if(file.Open(strPath,CFile::modeCreate|CFile::modeWrite,NULL))
{
WORD wSignature=0xFEFF;
file.Write(&wSignature,2);
file.Write(tBuf,nLen*sizeof(TCHAR));
file.Close();
}
}
}
catch (...)
{
TRACE(_T( "WriteToLog\n "));
}
}
怎么样才能在自己 的 程序中生成自己程序中收集到的数据并生成WORD格式的文件。谢谢 大家了
------解决方案--------------------
什么格式的数据?
最简单的情况就保存为文本文件,后缀名为doc即可
------解决方案--------------------
http://www.vckbase.com/document/viewdoc/?id=1174
这篇文章就可以解决
------解决方案--------------------
顶了再看。
------解决方案--------------------
后面扩展名为.doc就可以啊
------解决方案--------------------
事例代码:
void CDemoDoc::WriteToLog(CString strInfo,CString strPath)
{
try
{
CString tmpStr;
tmpStr.Empty();
CTime mTime;
mTime=CTime::GetCurrentTime();
tmpStr.Format(_T( "%04d-%02d-%02d %02d:%02d:%02d %s \r\n "),mTime.GetYear(),
mTime.GetMonth(),mTime.GetDay(),mTime.GetHour(),mTime.GetMinute(),mTime.GetSecond(),strInfo);
int nLen=tmpStr.GetLength();
TCHAR* tBuf=tmpStr.GetBuffer(nLen);
CFile file;
if(file.Open(strPath,CFile::modeRead,NULL))
{
file.Close();
if(file.Open(strPath,CFile::modeWrite,NULL))
{
file.SeekToEnd();
file.Write(tBuf,nLen*sizeof(TCHAR));
file.Close();
}
}
else
{
if(file.Open(strPath,CFile::modeCreate|CFile::modeWrite,NULL))
{
WORD wSignature=0xFEFF;
file.Write(&wSignature,2);
file.Write(tBuf,nLen*sizeof(TCHAR));
file.Close();
}
}
}
catch (...)
{
TRACE(_T( "WriteToLog\n "));
}
}