gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 05:05:16 25 4
gpt4 key购买 nike

我正在为我的工作做一个小程序(它与编程无关),以帮助他们进行许多测量和工作效率。

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

是否可以从我的 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;
}

最佳答案

关于c++ - 如何连接 C++ 和 Excel(从 C++ 程序输出到 Excel 电子表格),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44980928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com