title: How to interface C++ and Excel (Output from C++ program to an Excel spreadsheet)
body: <p>I am making a small program for my job (it has nothing to do with programming) to help them with the many measurements and efficiency of their job.</p>
  
  <p>I have made most of the program in a Console App in C++ with Code::Blocks.</p>
  
  <p>Would it be possible to yank the output of variables from my C++ and put them in certain cells in an Excel spreadsheet? I have looked around the internet for some forums but some do not work or have me use Visual Basics. Any clues or hints would help dramatically. Thanks. </p>
  
  <p>Source Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cmath&gt;
  
  
  //Function Prototypes -- *
  void DisplayMenu();
  void Bahama();
  int Colonial();
  int StormPanel();
  
  
  
  
  
   void DisplayMenu()
  {
  
  
      int a;
  
      std::cout &lt;&lt; "*---Display Menu---*\n";
      std::cout &lt;&lt; "1) Bahama/Colonial\n";
      std::cout &lt;&lt; "2) Strom Panel\n\n";
  
      std::cout &lt;&lt; "Type the corresponding number for\n";
      std::cout &lt;&lt; "the type of shutter you need calculated: ";
  
          std::cin &gt;&gt; a;
  
          switch(a)
          {
          case 1:
              Bahama();
              break;
          case 2:
              StormPanel();
              break;
  
          }
  
  
  }
  
  void Bahama()
  {
  
      int Token = 200;
  
      do{
  
      int SN; //Shutter Number
      int QSL; // Quantity of Shutter Louvers
  
      double W; //Width
      double H; //Hight
      double Sl; // Shutter Louvers (trail)
      double SL; // Size of Shutter Louvers
  
      float Sd = 3.7812; // Single Deduction
      float Dd = 5.6562; // Double Deduction
      float Td = 7.5312; // Triple Deduction
      float Qd = 9.4062; // Quadruple Deduction
      float QTd = 11.2812; // Quintuple Deduction
      float STd = 13.1562; // Sextuple Deduction
  
      float HL; // Hight multiplied by Length
  
      system("cls");
  
      std::cout &lt;&lt; "*----------------------------------------*\n\n";
      std::cout &lt;&lt; "What is the Width of the Bahama/Colonial shutter?\n";
      std::cout &lt;&lt; "(Whole Number or Decimal[Inches]): ";
          std::cin &gt;&gt; W;
  
      std::cout &lt;&lt; "*----------------------------------------*\n\n";
      std::cout &lt;&lt; "What is the Hight of the Bahama/Colonial shutter?\n";
      std::cout &lt;&lt; "(Whole Number or Decimal[Inches]): ";
          std::cin &gt;&gt; H;
  
  
  
      HL = W*H;
  
      system("cls");
  
      std::cout &lt;&lt; "*---------------------------------------------------------
  ----
  ---------------------------------------*\n\n";
      std::cout &lt;&lt; "Is this Shutter a . . ." &lt;&lt; "\n" &lt;&lt; "Single (1), Double 
  (2)," 
  &lt;&lt; "\n" &lt;&lt; "Triple (3), Quadruple (4)," &lt;&lt; "\n" &lt;&lt; "Quintuple (5), or 
  Sextuple 
  (6): ";
          std::cin &gt;&gt; SN;
  
  
      switch (SN)
      {
          case 1: Sl = W - Sd;
          break;
  
          case 2: Sl = W - Dd;
          break;
  
          case 3: Sl = W - Td;
          break;
  
          case 4: Sl = W - Qd;
          break;
  
          case 5: Sl = W - QTd;
          break;
  
          case 6: Sl = W - STd;
          break;
  
          default: Sl = W - Sd;
      }
  
      SL = Sl / SN;
  
  
  
  
  
  
      std::cout &lt;&lt; "\n\nWith a Width of [" &lt;&lt; W &lt;&lt;"] and a Hight of [" &lt;&lt; H &lt;&lt; 
  "]";
      std::cout &lt;&lt; " the Bahama/Colonial Shutters'. . .";
  
  
      std::cout &lt;&lt; "\n\nSide Slide: ";
          std::cout &lt;&lt; W - 3.3125;
  
      std::cout &lt;&lt; "\n\nSide Rails: ";
          std::cout &lt;&lt; H - 3.7187;
  
      std::cout &lt;&lt; "\n\nLouver Size: ";
          std::cout &lt;&lt; SL;
  
      // std::cout &lt;&lt; "\n\nNumber of Louvers: ";
         // std::cout &lt;&lt; NP;
  
      std::cout &lt;&lt; "\n\n*-----------------------------------------------------
  ----
  -------------------------------------------*\n\n\n";
  
      std::cout &lt;&lt; "Would you like to measure out another Bahama/Colonial 
  shutter?";
      std::cout &lt;&lt; "(1 = Yes)(2 = Main Menu)(0 = Quit): ";
          std::cin &gt;&gt; Token;
  
      switch (Token)
      {
      case 2: DisplayMenu();
  
      case 0: Token = 200;
      }
  
  
  
      } while (Token == 1);
  
  }
  
  
  
  
  int StormPanel()
  {
      std::cout &lt;&lt; "Storm Panel!";
  
      return 0;
  
  }
  
  
  
  int main()
  {
      DisplayMenu();
  
      return 0;
  }
  </code></pre>