I've written a VSTO DLL to perform a transform on a user-specified range of cells. I'm doing this in the following manner:
Globals.ThisAddIn.Application.EnableEvents = false;
int totRows=inputRange.Rows.Count;
int totCols=inputRange.Columns.Count;
for (int i = 1; i <= totRows; i++) {
for (int j = 1; j <= totCols; j++) {
if (((Range)inputRange.Cells[i, j]).Value2 != null) {
((Range)outputSheet.Cells[i, j]).Value2 = MyTransform(((Range)inputRange.Cells[i, j]).Value2);
}
}
}
Globals.ThisAddIn.Application.EnableEvents = true;
This method allows me to modify approximately 1.5 million cells/hour (I'm not counting time consumed by MyTransform()), which seems to me to be very slow.
Is there a more efficient way to read/write cells in VSTO?
If not, would converting this to an XLL (likely using Excel-DNA) be any faster? Any guess as to how much?