3

I am transforming some XML to view in MS Excel. There is a very good reference on how to create the schema - http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx. This blog is also useful.

I am having trouble inserting a formula into a cell, so: <Cell ss:Index="2" ss:Formula="=SUM(R[-3]C[0]:R[-1]C[0])"> <Data ss:Type="Number"></Data> </Cell> is pretty straightforward. This will sum the values in the row 3 rows above to the row 1 above.

However, the formula I need (in A1 style format, rather than R1C1) is =SUMIF(A:A,"Assignments",B:B).

I have tried many options, including

  • ss:Formula="=SUMIF(C[-1]:C[-1],Assignments,C[0]:C[0])" but the definition of the cell equals =SUMIF(A:A,Assignments,B:B) in this case.

  • ss:Formula="=SUMIF(C[-1]:C[-1],"Assignments",C[0]:C[0])" but the workbook becomes corrupt and won't open.

  • ss:Formula="=SUMIF(C[-1]:C[-1],'Assignments',C[0]:C[0])" but the definition of the cell equals 0 in this case.

The quotation marks are causing a problem. Does anyone know the correct syntax to get the required formula insert into a cell?

4

1 回答 1

4

答案是要注意 XML 文档转义字符。 我需要在 XML 文档中转义哪些字符?

所需代码中的行是:

ss:Formula="=SUMIF(C1:C1, &quot;Assignments&quot;,C[0]:C[0])"

于 2013-02-03T13:39:54.257 回答