私は現在、提供されたExcelスプレッドシートからの変換である半複雑な計算機を構築しています。
私はそのほとんどを釘付けにしましたが、Excelスプレッドシートには、6行7列の間で複数の計算が行われる部分がありますが、問題は、計算が特定の順序でまったく行われないことです。
したがって、たとえば、Row0[Column1]
を使用して計算され、を使用(Row2[Column4] * Row2[Column5])
しRow1[Column4]
て計算され(Row4[Column2] / Row5[Column1])
ます。
2D配列を使用することを考えましたが、値が特定の順序で計算されるため、値に達したときに値がないのではないかと心配しています。私の知る限り、Row1が最初に計算され、次にRow2、Row3などが計算されます。
したがって、Excelスプレッドシートの各セルに変数を作成せずに(そして適切に順序付けせずに)、C#を使用してこれを計算する方法はありますか?
私はあなたが可能であると思うものは何でも、どんな助け、アドバイス、ポインタ、本当に感謝します-私はそれを聞きたいです!
編集@dtbによって提供されるLazyクラスを実装した後、次のコードを取得しました。これは、ポインターと計算を含む、私が提供したExcelスプレッドシートの内容の直接のコピーです。
var sr = new Lazy<decimal>[6, 6];
sr[0, 0] = new Lazy<decimal>(() => sr[1, 0].Value - eNumber);
sr[0, 3] = new Lazy<decimal>(() => sr[0, 4].Value - sr[1, 0].Value - sr[1, 4].Value);
sr[0, 4] = new Lazy<decimal>(() => sr[0, 0].Value * edD);
sr[0, 5] = new Lazy<decimal>(() => sr[0, 0].Value);
sr[1, 0] = new Lazy<decimal>(() => sr[1, 5].Value);
sr[1, 4] = new Lazy<decimal>(() => sr[1, 0].Value * edD);
sr[1, 5] = new Lazy<decimal>(() => sr[2, 0].Value + sr[2, 5].Value);
sr[2, 0] = new Lazy<decimal>(() => eNumber * rRate);
sr[2, 4] = new Lazy<decimal>(() => sr[2, 0].Value * hdD);
sr[2, 5] = new Lazy<decimal>(() => sr[1, 5].Value);
sr[3, 1] = new Lazy<decimal>(() => sr[2, 5].Value);
sr[4, 2] = new Lazy<decimal>(() => eNumber * (ePc / 100) + sr[2, 0].Value * (hlPc / 100) - sr[3, 1].Value);
sr[5, 0] = new Lazy<decimal>(() => (sr[0, 0].Value + sr[1, 0].Value + sr[2, 0].Value) / ePerR);
sr[5, 2] = new Lazy<decimal>(() => sr[5, 0].Value / rLifecycle);
sr[5, 4] = new Lazy<decimal>(() => sr[5, 2].Value);
sr[5, 5] = new Lazy<decimal>(() => sr[5, 0].Value + sr[5, 2].Value - sr[5, 4].Value);
ただし、次のエラーが発生します
ValueFactory attempted to access the Value property of this instance.
エラーをグーグルで検索すると、スパム検索タイプのWebサイトが多数返されます。
マルコ