Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi!
I am writing this program in visual c in which i need to take values which are in an excel spreadsheet (or from .csv format (whichever is easier!)) and put it into an array for doin some further computation. I dont need to write any data into the excel sheet. I just need the values frm there. I have the .xls or .csv file ready with its name and location known already. Im not an advanced programmer or anything of the sort so please tell me what header files to include as well!!! Thanks in advance Gautam |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Gautam,
If it just has to be done once the easy way is to write it out from Excel in CSV format. Then use get() to read the file a character at a time, putting them into a char a[], looking for a comma. Once the comma is found, manipulate the characters in a[] as needed. E.g., use atoint() or something to convert to integer. Here is an example of reading characters. #include <iostream.h #include <fstream.h int main() { ifstream inFile("test.txt", ios::in); if(!inFile){ cerr << " File " << "test.txt" << " could not be opened for input." << endl; } ofstream outFile("out.txt", ios::out); if(!outFile){ cerr << " File " << "out.txt" << " could not be opened for output." << endl; } char c; while((c = inFile.get()) != EOF ){ outFile.put(c); } Here, the characters are just being echoed to outfile rather than being stored in an array. Hope this gives you some hints, but not the complete assignment! Good luck, Ed "Gautam" wrote in message ups.com... Hi! I am writing this program in visual c in which i need to take values which are in an excel spreadsheet (or from .csv format (whichever is easier!)) and put it into an array for doin some further computation. I dont need to write any data into the excel sheet. I just need the values frm there. I have the .xls or .csv file ready with its name and location known already. Im not an advanced programmer or anything of the sort so please tell me what header files to include as well!!! Thanks in advance Gautam |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hmmm..thanks that was quite helpful!
But say if i need to import the data from an excel spreadsheet....? If there is a way to import from excel, isnt it likely to be easier? since i guess it would recognise the entire floating point number in a cell instead of requiring to convert it with some command repeatedly like atof() or smth? Gautam Ed wrote: Gautam, If it just has to be done once the easy way is to write it out from Excel in CSV format. Then use get() to read the file a character at a time, putting them into a char a[], looking for a comma. Once the comma is found, manipulate the characters in a[] as needed. E.g., use atoint() or something to convert to integer. Here is an example of reading characters. #include <iostream.h #include <fstream.h int main() { ifstream inFile("test.txt", ios::in); if(!inFile){ cerr << " File " << "test.txt" << " could not be opened for input." << endl; } ofstream outFile("out.txt", ios::out); if(!outFile){ cerr << " File " << "out.txt" << " could not be opened for output." << endl; } char c; while((c = inFile.get()) != EOF ){ outFile.put(c); } Here, the characters are just being echoed to outfile rather than being stored in an array. Hope this gives you some hints, but not the complete assignment! Good luck, Ed "Gautam" wrote in message ups.com... Hi! I am writing this program in visual c in which i need to take values which are in an excel spreadsheet (or from .csv format (whichever is easier!)) and put it into an array for doin some further computation. I dont need to write any data into the excel sheet. I just need the values frm there. I have the .xls or .csv file ready with its name and location known already. Im not an advanced programmer or anything of the sort so please tell me what header files to include as well!!! Thanks in advance Gautam |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Complex conditional summing - array COUNT works, array SUM gives#VALUE | Excel Worksheet Functions | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming |