views:

133

answers:

0

Hi, I am getting error while using the Excel Interops set_Value on a range. Any help/suggestion will be valuable.

This is the code which is failing.

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application xlApp = new Excel.ApplicationClass(); Excel.WorkBook WB = xlApp.Workbooks.Add(Type.Missing); Excel.WorkSheet WS = WB.Sheets[1] as Excel.WorkSheet; object obj = (WS.get_Range("A1:D10") as Excel.Range).get_Value(Excel.XLRangeValueDataType.XLRangeValueMSPersistXML);

(WS.get_Range("A1:D10") as Excel.Range).set_Value(Excel.XLRangeValueDataType.XLRangeValueMSPersistXML,obj);

The code fails here. I am setting the same object value which i am getting from excel range. The exception shown is System.NotImplementedException.

I am clueless at this point if it is the office interop doesn't support XLRangeValueMSPersistXML while setting the value back to the excel range.