Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ xlw:如何使用新的typedef从Excel单元格中获取std::string(并可能填充std::map)_C++_Templates_Xlw - Fatal编程技术网

C++ xlw:如何使用新的typedef从Excel单元格中获取std::string(并可能填充std::map)

C++ xlw:如何使用新的typedef从Excel单元格中获取std::string(并可能填充std::map),c++,templates,xlw,C++,Templates,Xlw,导言 我指的是MarkJoshi等人的ExcelCAPI包装器 在开始我的示例、我的试用和我的问题之前,先说几句关于如何复制这些代码的话:一旦您从其网站下载并安装了xlw,您应该找到一个名为XLL\u Project,其内容是Visual Studio解决方案(Template.sln)的文件夹如果在安装过程中选择了此IDE/平台;此解决方案由一个cppfinterface.h组成,即定义final.xll中应包含哪些函数的头文件,以及一个source.cpp,指定所述函数的行为方式 代码 让像

导言

我指的是MarkJoshi等人的ExcelCAPI包装器

在开始我的示例、我的试用和我的问题之前,先说几句关于如何复制这些代码的话:一旦您从其网站下载并安装了
xlw
,您应该找到一个名为
XLL\u Project
,其内容是Visual Studio解决方案(Template.sln)的文件夹如果在安装过程中选择了此IDE/平台;此解决方案由一个
cppfinterface.h
组成,即定义final.xll中应包含哪些函数的头文件,以及一个
source.cpp
,指定所述函数的行为方式

代码

让像下面这样的接口函数位于
cppainterface.h
中,其行为位于
source.cpp

// ===== cppinterface.h =====

std::string // Asks the user to enter the number of pancakes eaten for breakfast by different people. Analyzes the data and output which person ate the most pancakes
    PancakeGlutton(const MyArray& people, // Range of people
                   const MyArray& pancakeNumber // Range of pancakes eaten by each person
                  );

因此,无法将其转换为能够管理字符串的容器:只需加倍。尽管在与
xlw
Joshi相关的章节中,Joshi说

[…]类
MyArray
也通过
MyContainers.h
中的
typedef
定义。默认设置为
typedef
std::vector
。它必须定义了
.size()
、一个采用大小的构造函数和
运算符[]

…仅添加

typedef std::vector< std::string > MyStrArray;
typedef std::vectorMyStrArray;
既不发送到
mycontainers.h
,也不发送到我的项目的任何头文件

问题

  • 如何通过读取 Excel中字符串的范围
  • 如何通过定义新容器
    typedef
    根据我想要的类型/类别来管理 所有可能的Excel输入

  • MyArray类仅用于表示双精度数组。typedef是这样的,你可以使用你最喜欢的类


    CellMatrix类允许您输入任何类型的数据。您只需测试CellMatrix的每个元素的类型,然后对其执行所需操作。

    mycontainers.h是示例模板的一部分吗?看起来它不是xlw文档的一部分。我想你可以更改typedef,它是一个外部依赖项。我试图通过添加该定义来修改代码,但它无论如何都无法构建。我想其他事情必须在别处做,但我不知道在哪里或如何做。你试过使用
    typedef std::vectorMyStrArray?Excel字符串应该是unicode。
    
    // ===== mycontainers.h =====
    // Line 68
    // ...
       typedef std::vector<double> MyArray;
    
    typedef std::vector< std::string > MyStrArray;