0

I'm newbie in C#. I tried to insert strings from DataTable into Excel cells formulas, but unsuccesfully. For example, I have

=ROUND(R[-2]C*IF(R[-1]C="";R[-1]C17;R[-1]C)/(IF(R[-1]C="";R[-1]C17;R[-1]C));2)

as value. I also tried to make

=ROUND(R[-2]C*IF(R[-1]C=\"\";R[-1]C17;R[-1]C)/(IF(R[-1]C=\"\";R[-1]C17;R[-1]C));2)

But I got an exception from HRESULT: 0x800A03EC In the last example debugger shows proper string, but I also got that exception.

Also, it works, when I put this code:

Globals.Wirksheet1.Cells.Range["A100"].Value2 = @"=ROUND(R[-2]C*IF(R[-1]C="""",R[-1]C17,R[-1]C)/(IF(R[-1]C="""",R[-1]C17,R[-1]C)),2)";

But I need to get values from DataTable, also I don't know how to add @ to string. Please, explain me how to solve this problem? Thanks

4

1 に答える 1

0

答えのために。

OPは次のよ​​うに述べています。

テーブルデータの値を次のように変更しました

=ROUND(R[-2]C*IF(R[-1]C=CONCATENATE(CHAR(34),CHAR(34)),R[-1]C17,R[-1]C)/(IF( R[-1‌ ]C=CONCATENATE(CHAR(34),CHAR(34)),R[-1]C17,R[-1]C)),2)

于 2014-01-22T18:17:41.383 に答える