0
我想提出一個小程序,我的工作(它無關編程),以幫助他們在多次進行測量,他們的工作效率。如何連接C++和Excel(輸出從C++程序到Excel電子表格)
我做了大部分程序中++控制檯應用程序用C代碼與:: Blocks的。
是否可以抽出來,從我的C++變量輸出,並把他們在某些細胞在Excel電子表格?我已經環顧了一些論壇的互聯網,但有些不工作或讓我使用Visual Basics。任何線索或提示都會有很大幫助。謝謝。
源代碼:
#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;
}
您應該使用jmcnamara的優秀libxlsxwriter。它是免費的,BSD許可,並且工作得非常好。他還提供圖書館,在許多不同的語言相同的API,所以技能轉讓: https://github.com/jmcnamara/libxlsxwriter –
沒有開箱即用的解決方案。如果你想_TO猛拉variables_的輸出您可能需要使用一些圖書館或學習Excel文件格式。我反對學習excel文件格式。 – Ron
任何特別有用的庫,你會建議? –