save data as csv or excel
-
im using VC++6 MFC, i want to create and save some data out to a file such as a csv file or even better a excel file. I know of CFileDialog to bring up a save dialog but how do i pump out data in a csv or excel format thanks
-
im using VC++6 MFC, i want to create and save some data out to a file such as a csv file or even better a excel file. I know of CFileDialog to bring up a save dialog but how do i pump out data in a csv or excel format thanks
-
have your data as comma seperated values each row seperated by newline adn then jsut give the file .csv extension. That's how I used to do it.
how did you write the data out thou, i see there is CArchive but doesnt appear to do much!!
-
im using VC++6 MFC, i want to create and save some data out to a file such as a csv file or even better a excel file. I know of CFileDialog to bring up a save dialog but how do i pump out data in a csv or excel format thanks
viperlogic wrote:
im using VC++6 MFC, i want to create and save some data out to a file such as a csv file or even better a excel file.
To communicate with Excel, you can use its ODBC driver, or Excel automation.
viperlogic wrote:
I know of CFileDialog to bring up a save dialog...
CFileDialog
has nothing to do with how the data is saved. It is for filename selection only.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
im using VC++6 MFC, i want to create and save some data out to a file such as a csv file or even better a excel file. I know of CFileDialog to bring up a save dialog but how do i pump out data in a csv or excel format thanks
-
how did you write the data out thou, i see there is CArchive but doesnt appear to do much!!
There must be at least dozen ways to write a file. I suppose if you want something MFC there is CFile or CStdioFile? Perhaps even this http://www.codeproject.com/file/stdiofileex.asp#xx1295590xx[^] if you want some unicode support.
-
im wanna go down the csv route. i am using the CArchive as follows CFile f; char strFilter[] = { "csv Files (*.csv)|*.csv|All Files (*.*)|*.*||" }; CFileDialog FileDlg(FALSE, ".csv", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite); CArchive ar(&f, CArchive::store); ar<< m_Make << m_Model << m_Year << m_Mileage << m_Owner; ar.Close(); } else return; f.Close(); the above is coming out in one cell with a rectangular box after each string how do i get ride of those retangular boxes and have a string in a seperate cell thanks
-
im wanna go down the csv route. i am using the CArchive as follows CFile f; char strFilter[] = { "csv Files (*.csv)|*.csv|All Files (*.*)|*.*||" }; CFileDialog FileDlg(FALSE, ".csv", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite); CArchive ar(&f, CArchive::store); ar<< m_Make << m_Model << m_Year << m_Mileage << m_Owner; ar.Close(); } else return; f.Close(); the above is coming out in one cell with a rectangular box after each string how do i get ride of those retangular boxes and have a string in a seperate cell thanks
viperlogic wrote:
the above is coming out in one cell
But what does it look like when viewed with Notepad? Try:
CStdioFile f;
...
ar << m_Make << ',' << m_Model << ',' << m_Year << ',' << m_Mileage << ',' << m_Owner << endl;
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
viperlogic wrote:
the above is coming out in one cell
But what does it look like when viewed with Notepad? Try:
CStdioFile f;
...
ar << m_Make << ',' << m_Model << ',' << m_Year << ',' << m_Mileage << ',' << m_Owner << endl;
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
still get the boxes as seen below a,b,c,d,e
-
still get the boxes as seen below a,b,c,d,e
Which implies that
m_Make
,m_Model
,m_Year
,m_Mileage
, andm_Owner
have an odd character in them. Yes?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
-
Which implies that
m_Make
,m_Model
,m_Year
,m_Mileage
, andm_Owner
have an odd character in them. Yes?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
CString m_Make="a"; CString m_Model ="b"; CString m_Year ="c"; CString m_Mileage ="d"; CString m_Owner="e"; for testing purposes i have them as above, so where is this box coming from!!!
-
CString m_Make="a"; CString m_Model ="b"; CString m_Year ="c"; CString m_Mileage ="d"; CString m_Owner="e"; for testing purposes i have them as above, so where is this box coming from!!!
viperlogic wrote:
so where is this box coming from!!!
Unicodedness of your program without writing the unicode-header? A decent file editor (as opposed to a CEdit-gone-application like notepad) like Ultraedit would show it.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.