【发布时间】:2013-03-06 22:35:56
【问题描述】:
我正在创建一个类来帮助创建 excel 文件。我正在考虑在计算最终输出之前将工作表数据存储在内存中的各种方法。理想情况下,我想做std::string myArray["Sheet1"][3][7] = "this is the value of row 3 column 7 in worksheet Sheet1" 之类的事情,但这在 C++ 中似乎是不可能的......或者是吗?
有什么简单的方法可以解决这个问题,还是我必须创建一个多维向量并拥有一个带有相应索引的单独数组来确定工作表名称?即,
std::vector<std::vector<std::vector<std::string> > > Worksheet;
std::vector<std::string> WorksheetNames;
// whenever I create a new worksheet...
WorksheetNames[7] = "Sheet1";
// and then to reference that worksheets' data...
Worksheet[7][1][1] = "value of row 1 column 1";
class ExcelSheet {
string Code, Worksheet, Style; // temp vars for data manipulation
std::vector<std::vector<std::vector<std::string> > > Worksheet;
public:
ExcelSheet();
ExcelSheet(int,int);
~ExcelSheet();
void Create();
void Destroy();
bool SetEntryValue(std::string szWorksheet, int nColumn, int nRow);
bool SetEntryStyle(std::string szWorksheet, int nColumn, int nRow);
};
【问题讨论】:
-
你的回答可能很优雅,“结构”对我来说毫无价值/没有任何解释。您愿意详细说明一下吗?
标签: c++ arrays visual-c++ vector