Dylan R.
Dylan R.

Reputation: 39

How to interface C++ and Excel (Output from C++ program to an Excel spreadsheet)

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.

I have made most of the program in a Console App in C++ with Code::Blocks.

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.

Source Code:

#include <iostream>
#include <cstdlib>
#include <cmath>


//Function Prototypes -- *
void DisplayMenu();
void Bahama();
int Colonial();
int StormPanel();





 void DisplayMenu()
{


    int a;

    std::cout << "*---Display Menu---*\n";
    std::cout << "1) Bahama/Colonial\n";
    std::cout << "2) Strom Panel\n\n";

    std::cout << "Type the corresponding number for\n";
    std::cout << "the type of shutter you need calculated: ";

        std::cin >> 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 << "*----------------------------------------*\n\n";
    std::cout << "What is the Width of the Bahama/Colonial shutter?\n";
    std::cout << "(Whole Number or Decimal[Inches]): ";
        std::cin >> W;

    std::cout << "*----------------------------------------*\n\n";
    std::cout << "What is the Hight of the Bahama/Colonial shutter?\n";
    std::cout << "(Whole Number or Decimal[Inches]): ";
        std::cin >> H;



    HL = W*H;

    system("cls");

    std::cout << "*---------------------------------------------------------
----
---------------------------------------*\n\n";
    std::cout << "Is this Shutter a . . ." << "\n" << "Single (1), Double 
(2)," 
<< "\n" << "Triple (3), Quadruple (4)," << "\n" << "Quintuple (5), or 
Sextuple 
(6): ";
        std::cin >> 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 << "\n\nWith a Width of [" << W <<"] and a Hight of [" << H << 
"]";
    std::cout << " the Bahama/Colonial Shutters'. . .";


    std::cout << "\n\nSide Slide: ";
        std::cout << W - 3.3125;

    std::cout << "\n\nSide Rails: ";
        std::cout << H - 3.7187;

    std::cout << "\n\nLouver Size: ";
        std::cout << SL;

    // std::cout << "\n\nNumber of Louvers: ";
       // std::cout << NP;

    std::cout << "\n\n*-----------------------------------------------------
----
-------------------------------------------*\n\n\n";

    std::cout << "Would you like to measure out another Bahama/Colonial 
shutter?";
    std::cout << "(1 = Yes)(2 = Main Menu)(0 = Quit): ";
        std::cin >> Token;

    switch (Token)
    {
    case 2: DisplayMenu();

    case 0: Token = 200;
    }



    } while (Token == 1);

}




int StormPanel()
{
    std::cout << "Storm Panel!";

    return 0;

}



int main()
{
    DisplayMenu();

    return 0;
}

Upvotes: 0

Views: 7129

Answers (1)

Related Questions