-4
  1. read Excel w/ C++ (microsoft vis studio)

  2. See tutorial: https://www.youtube.com/watch?v=EjJY7yA5SWw

  3. Here's my code:

    *ifstream FILE("USE THIS FILE.xls");
        //
        string date; string companyTicker; string companyName; int year1; int til; int month; int year2; int asdf;
        while(FILE>> date >>  companyTicker >> companyName >> year1 >> til >> month >> year2 >> asdf)
        {
            std::cout << date << ", " << companyTicker <<
            ", " << companyName << ", " << year1 << ", " << til << ", " << month << ", " << year2 << ", " << asdf << endl;
        }*

I've also gone on another tutorial where istream::getline is asked, of course this will cause an error "no instance of overloaded function". nothing online has been able to diagnose that issue.

Thanks all!

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
  • 3
    If you don't want downvotes - present a [mcve] in readable condition. – Ted Lyngmo Nov 02 '20 at 21:30
  • 2
    And see [ask] and maybe take the [tour] too. – BigBen Nov 02 '20 at 21:31
  • Please give the full error messages or expected and actual behaviour – Alan Birtles Nov 02 '20 at 21:35
  • 1
    The video is about reading a text file. xls is not a text file format (did you try opening an xls file in notepad.exe for example?). Do you really need to read xls? Or can you first export the xls file to a csv file and then read that? – Werner Henze Nov 02 '20 at 21:35
  • The tutorial is a bit off. "_it is called a file pointer_" - No, an `ifstream` is not called a file pointer. A `FILE*` is a `FILE` pointer though, which brings me to the variable name you use for your `ifstream`. The variable name `FILE` may conflict with `std::FILE`, especially since you are probably `using namespace std;` as they do in the tutorial (which you should avoid). – Ted Lyngmo Nov 02 '20 at 21:45
  • @AlanBirtles the program outputs nothing ("press any key to continue") If THIS is an error (found at the bottom of visual studio) then this is what I get: "'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file." There are other things that allude to "cannot find the PDB file"? Hope the "C:\Windows... isn't doxable information Expectable output would be to show the data from my CSV in C++ I guess...I'm a tremendous newbie at coding et al Thanks all – TheFemaleHessian 1 min ago – TheFemaleHessian Nov 02 '20 at 21:48
  • @TheFemaleHessian Put the necessary information inside the question by [editing](https://stackoverflow.com/posts/64653614/edit) the question. You mention one important detail - You are not actually trying to read an Excel file but a CSV file (probably exported from an Excel file, correct?). This is a much simpler problem to solve and there are tons of questions and answers here on SO solving that very problem. – Ted Lyngmo Nov 02 '20 at 21:53
  • @TedLyngmo, I can't use Namespace? Why? Thank you Is there any way to read csv files you can suggest? – TheFemaleHessian Nov 02 '20 at 21:54
  • @TheFemaleHessian You _can_ do `using namespace std;` but it's not recommended: [Why is `using namespace std;` considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice). Search here on SO and I'm sure you'll see a [large amount](https://stackoverflow.com/search?q=%5Bc%2B%2B%5D+csv) of examples of how to read CSV files. – Ted Lyngmo Nov 02 '20 at 21:56
  • @Sneftel , i did this and the same empty console/output appeared – TheFemaleHessian Nov 02 '20 at 22:26
  • There are open source `c` and `c++` libraries that read .xls or .xlsx files. They are however not really for a person who is new to the language. CSV is simpler to use to exchange between excel and c++ – drescherjm Nov 02 '20 at 22:36

1 Answers1

2

The tutorial you linked to shows a text file with fields separated by whitespace , which is how stream input in C++ is delimited. An XLS file is in a proprietary binary format, and cannot be directly read (without a library specifically designed for reading XLS files. Save your data as a tab-delimited file if you want to easily read it from C++.

Sneftel
  • 40,271
  • 12
  • 71
  • 104
  • @Alan Birtles the program outputs nothing ("press any key to continue") If THIS is an error (found at the bottom of visual studio) then this is what I get: "'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file." There are other things that allude to "cannot find the PDB file"? Hope the "C:\Windows... isn't doxable information Expectable output would be to show the data from my CSV in C++ I guess...I'm a tremendous newbie at coding et al Thanks all – TheFemaleHessian Nov 02 '20 at 21:46
  • 1
    Thanks @TedLyngmo! – TheFemaleHessian Nov 02 '20 at 21:49