Reference: I've looked at the posting Open excel file with Mathematica.
My intention is to be able to use Excel's RTD capability in order to pull market data into Mathematica. To my knowledge, this can be done, at the least, by having Excel use the RTD link, then using NETLINK to grab the value from Excel. At some point, it would be nice to have Mathematica pulling real time data from an Excel RTD link, but for now the RTD link value is only updated once per day.
Needs["NETLink`"]
PullValue[file_String] :=
Module[{excel, workbook, worksheet, RTDvalue},
NETBlock[InstallNET[];
excel = CreateCOMObject["Excel.Application"];
If[! NETObjectQ[excel], Return[$Failed], excel[Visible] = True;
workbook = excel@Workbooks@Add[];
worksheet = workbook@Worksheets@Item[1];
worksheet@Range["A1"]@Value =
"=ProphetX|QUOTE!'@CT@A?SettlementPrice'";
RTDvalue = worksheet@Range["A1"]@Value;
workbook@SaveAs[file];
workbook@Close[False];
excel@Quit[];]];
LoadNETType["System.GC"];
GC`Collect[]
RTDvalue];
outputfile = "C:\\Temp\\demo.xlsx";
Quiet[DeleteFile[outputfile]];
PullValue[outputfile];
The =ProphetX|QUOTE!'@CT@A?SettlementPrice' is the RTD portion, which at this point is putting a value into the saved Excel file, which should be correct. Sometimes when dealing with RTD links, I've noticed that I need to use FormulaArray, but @value seems to be working fine here.
Print[RTDvalue] is outputting -2146826246, instead of the correct value of ~ 81.26
So, I am wondering how I can get those values RTD values, which have gone into an Excel cell, into Mathematica, like they did in the posted link. Also, any direction or thought on how I could eventually have the data coming into Mathematicain real time.
Dynamic[Refresh[ExcelRead["A2"], UpdateInterval -> 0]]. – Rod Jul 02 '13 at 20:53NetBlock, isNETBlock– Murta Feb 26 '15 at 15:34