| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Checking an xls file against another
Hi people
im learning C++ bit by bit, and ive made some very basic programs, like you select WV in a combo box, and it will display wolverhampton on the form. my manager has asked me to try and make a program what checks two excel files ( .xls ) to see if there is a duplicate on one of them. for example each xls file contains a list of clients, the same name cannot be on both files. so lets say the first file has "mr john smith" "142 warbreck road" the program would read this, then read the other file to make sure mr smith is not also listed in the file ( duplicated ) im not going to be as cheeky as to say will someone type this code for me, chances are no one would reply anyway lol but if you could tell me to go learn about this component.. or google this word, etc etc it would really help me in learning the parts i need to know.. Any help would be greatly appreciated. Brad |
|
#2
|
||||
|
||||
|
AFAIK, is the Excel file format stil proprietary, so not easily (if at all) read from C/C++.
if it were an OpenOffice file, I'd might be able to help you, but not with Excel. Would it be possible to export the data to a CSV (comma seperated values) file first? in that case it'd be easy...
__________________
This is my code. Is it not nifty? "The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools." ---Douglas Adams Join the Itsacon fanclub! Zero Tolerance: Spammers banned so far: 280
![]() |
|
#3
|
|||
|
|||
|
Yep that would be an option, im flexible
|
|
#4
|
||||
|
||||
|
In that case it's quite doable.
Reading a CSV or TSV file in C/C++ is easily done using the normal file I/O functions. You read the entire first file to memory, and then read the second file, comparing each item with those store, to see if it's a duplicate. You might want to have a look at the data types in the C++ Standard Template Library (STL). It has a lot of default listtypes you can use, so you don't have to fiddle around using malloc() and the like. Especially for lists of objects, which you'll be generating, it can save a lot of development time. |
|
#5
|
|||
|
|||
|
brilliant, il give this a try tomorrow, although im lost when it comes to specifying what the program should be searching for.
i think it would be best if i made it check the telephone numbers, as that would eliminate the chance of someone typing the name or address incorrectly. so how would you go about making the program read the telephone numbers and ignoring the rest of the data, or doesnt it work like that.. sorry for the basic questions in the mean time il try googling some words. Thanks again for your help |
|
#6
|
|||
|
|||
|
hm, well ive gotten a little lost as to opening a file to memory.. read so many different posts on the net about how to do it, its clouded the picture.
not sure if i should point out in using BCB, which has a form which i can put components on to, to make life easier. ive added a StringGrid to the form, and have figured out how to change the columns labels Code:
void __fastcall TForm2::FormCreate(TObject *Sender)
{
StringGrid1->Cells[1][0] = "Date";
StringGrid1->Cells[2][0] = "Duplicated by";
StringGrid1->Cells[3][0] = "Located in";
StringGrid1->Cells[4][0] = "Client name";
StringGrid1->Cells[5][0] = "no. & street";
StringGrid1->Cells[6][0] = "town";
StringGrid1->Cells[7][0] = "Postcode";
}
and at a guess i would have to use a variable to tell the program to insert the text in to the next row down? maybe.. Code:
if lineprompt=1
{
StringGrid1->Cells[1][1] = "23/01/06";
StringGrid1->Cells[2][1] = "Bragot";
StringGrid1->Cells[3][1] = "Jacqui's file";
StringGrid1->Cells[4][1] = "Mr Smith";
StringGrid1->Cells[5][1] = "10 downing street";
StringGrid1->Cells[6][1] = "london";
StringGrid1->Cells[7][1] = "IP30 0QJ";
}
although i know "bragot" "jacqui's file" etc would be inserted using a string, but then how would the program know where to point the string to..... as you can tell im a little ( HA ) lost. but im trying ![]() |
|
#7
|
|||
|
|||
|
ok been a little while since i last posted here, heres what ive figured out
ive managed to open a file to memory, and i can do a search by typing in an address in to an edit box, which then checks the string against the master file. if it is found then it displays duplicate found, else not duplicated. Code:
if (MemoryList->IndexOf(a) > -1)
{
Edit5->Color = clRed;
Edit5->Text = "duplicated!";
PlaySound("C:\\Documents and Settings\\Administrator\\Desktop\\siren.wav", NULL, SND_FILENAME | SND_ASYNC);
}
else
{
Edit5->Color = clLime;
Edit5->Text ="Lead is not duplicated!";
}
the thing is, i havew to type the name of the address exactly. like if i type 16 adlesbury road it will be found as it exists on the master file however if i was to type 16 adlesbury it would not be found as i didnt put "road" on the end the reason i ask this, is because some of the entries on the master file have rd instead of road , ave instead of avenue , cres instead of crescent etc etc is there a way i can make a wildcard for instance so i dont have to type the exact name, only part of it? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Checking an xls file against another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|