当我通过 C++ 中的 ofstream 将我的计算导出到 ODS (Apache OpenOffice) 文件时,数字会正确显示在那里,但是我无法在该特定 ODS 文件中进行任何计算。
例如,当我尝试在 A1 上添加 0.9191,在 A2 上添加 0.5757 时,=SUM(A1:A2) 返回零。
我试图通过格式化单元格来解决这个问题,但到目前为止还没有奏效。有什么建议么?谢谢你。
编辑:执行导出工作的代码部分。
string datafolder; datafolder = "c:/Users/cousinvinnie/Desktop/Code Vault/ArmaTut3/" + Jvalue;
string graph_path = datafolder + "/Graphavgs.ods"; ofstream graphavgs; graphavgs.open(graph_path);
for(int ctr = 0; ctr<cycledata; ctr++){
cyclepoints = (howmanyDC + 1) * (ctr + 1);
graphavgs<<(ctr + 1)<<" ";
calcguy = sum((wholedata.row(cyclepoints))) / nextgenpop;
secondbiggiesavg(ctr) = -log(calcguy);
graphavgs<<secondbiggiesavg(ctr)<<" ";
calcguy = sum((thirdbiggest.row(cyclepoints))) / nextgenpop;
thirdbiggiesavg(ctr) = -log(calcguy);
graphavgs<<thirdbiggiesavg(ctr)<<" ";
calcguy = sum((matrixavgs.row(cyclepoints))) / nextgenpop;
avgmatrixdata(ctr) = -log(calcguy);
graphavgs<<avgmatrixdata(ctr)<<" "<<endl;
}
graphavgs.close();
此代码创建 Graphavgs.ods 文件。在那个文件中我有
1 0.111753 0.182331 0.358724
2 0.147015 0.259202 0.48334
3 0.195855 0.362397 0.648719
4 0.25348 0.476696 0.839261
5 0.314722 0.618828 1.0633
6 0.420704 0.857286 1.37501
7 0.536699 1.1179 1.69503
8 0.76933 1.56382 2.13464
9 0.90525 1.89921 2.42443
10 1.15678 2.41533 2.82584
现在这些数字不被视为数字。当我尝试对它们执行函数时,例如 =SUM(A1:A2),返回为零。
当我执行 =LN(A1) 时,返回的是 #VALUE!
已解决:查找并用逗号替换所有点。