使用数组(string)填充Excel范围的.Formula's
(我正在使用C#,但语言应该不重要。)
range.Formula = array;
不会导致错误,但行为完全一样
range.Value2 = array;
:公式显示为“值”。 当我做F2 , input一个单元格,公式得到正确的评估。
这是我如何填充数组:
var array = new string[rows, cols]; //Fill the array. for (long iRow = 0; iRow < rows; iRow++) { for (long iCol = 0; iCol < cols; iCol++) { //Put a counter in the cell. Eg "=A1+1+100000" array[iRow, iCol] = "=A1+" + (iCol+1) + "+" + (iRow+1) * (rowStep); } }
如果我使用object[,]
而不是string[,]
object[,]
则适用于我。
不要问我为什么,但是这(第二行)修正了它:
range.Formula = array; range.Formula = range.Formula;
不幸的是,这需要两倍的时间。 有没有更好的方法来避免这种惩罚?
上面的解决scheme是由这个职位通知。
- 将PrintArea设置为“使用EPPlus打印整个工作簿”
- Excel自动化,如何检测用户是否在Excel工作表中运行macros或单击“运行macros”CommandBarControl?
- 格式化十进制前的2位数字和十进制后的2位数字,Excel Interop
- 如何将Excel工作表写入MemoryStream?
- 如何更改Excel数据透视表的源数据
- C#从excel文件读取数据结果在###
- Excel Interop – 在图表中隐藏类别
- 用Microsoft.Office.Interop.Excel和CLR在Python中打印Excel文件?
- 无法在空引用上执行运行时绑定 – 清空Excel单元格