任何人都可以告诉我为什么这不起作用
Excel.Worksheet ws_res = (Excel.Worksheet)
wb.Worksheets.Add(mis, mis, mis, mis);
Excel.Range range_res = (Excel.Range)ws_res.get_Range("A1","HM232");
range_res.FormulaArray =
"=ROUND((IF((IF(Sheet4!A1:HM232=1,0,"+
"IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))=1,0,"+
"IF((IF(Sheet4!A1:HM232=1,0,"+
"IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))=0,1,("+
"IF(Sheet4!A1:HM232=1,0,"+
"IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))))),0)";
但是这样做
Excel.Worksheet ws_res = (Excel.Worksheet)
wb.Worksheets.Add(mis, mis, mis, mis);
Excel.Range range_res = (Excel.Range)ws_res.get_Range("A1","HM232");
range_res.FormulaArray =
"=ROUND((IF(Sheet4!A1:HM232=1,0,IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232))),0)";
=============================================== ======
但如果我将上述两个公式复制并粘贴到excel-2007的公式栏并按Ctrl + Shift + Enter,则两者都能完美运行!
=============================================== ======
我也改变了以上两个公式A1:HM232到R1C1:R232C221,再次来自c#,较短的一个工作正常,但较长的一个仍然会产生异常!
答案 0 :(得分:0)
它对我有用。我必须假设你没有Sheet4(不太可能,因为较短的公式起作用)或者你在删除引号,“+”和换行符时输了一个错字。以下是我现在在公式栏中的内容:
=ROUND((IF((IF(Sheet4!A1:HM232=1,0,IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))=1,0,IF((IF(Sheet4!A1:HM232=1,0,IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))=0,1,(IF(Sheet4!A1:HM232=1,0,IF(Sheet4!A1:HM232=0,1,Sheet4!A1:HM232)))))),0)
答案 1 :(得分:0)
如果字符串超过255个字符,则Excel执行FormulaArray时会遇到一些问题。烦人。 VBA有一个圆形的方式,C#,没办法!