如何连接C ++和Excel(从C ++程序输出到Excel电子表格)

我正在为自己的工作做一个小程序(与编程无关),以帮助他们完成工作的多种度量和效率。

我已经使用Code :: Blocks在C ++的控制台应用程序中完成了大部分程序。

是否可以从我的C ++中抽出variables的输出,并将它们放入Excel电子表格的某些单元格中? 我已经环顾了一些论坛的互联网,但有些不工作,或让我使用Visual Basic。 任何线索或提示将有助于戏剧性。 谢谢。

源代码:

#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; }