I'm using the NETLink package to build a Excel file and trying to fill it with some data as this:
Needs["NETLink`"];
InstallNET[];
(*xls = NETNew["Microsoft.Office.Interop.Excel.ApplicationClass"];*)
xls = CreateCOMObject["Excel.Application"];
xls@Visible = True;
wb = xls@Workbooks@Add[]
ws = wb@Worksheets@Item[1]
it works with code :
ws@Cells[1, 1]@Value = 100;
ws@Cells[2, 2]@Value = 200;
ws@Cells[3, 3]@Value = 300;
but gives no result with code:
For[i=1,i<10,i++,
ws@Cells[i, i]@Value = i*100
]
so,what's wrong with the loop case ? Thanks!
(*Solution*)
(*define func.*)
wsGetCell[i_,j_]:=ws@Cell[i,j]
(*loop*)
For[i=1,i<10,i++,
wsGetCell[i, i]@Value = i*100
]
Cells[1,1]
would just return$Failed
. Anyway, sinceCells[i,i]
is held during the evaluation those notes apply: Function in Table. $\endgroup$Activate
function but it doesnot work. $\endgroup$