Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Setting Excel Cell values using C#

Hi,

There is an Excel Addin ( developed in C#) having requirement to
populate the data in Workbook after fetching it from DB, based on the
Cell selected by user.

So if User selects "A1" cell, and the dataset retrieved from DB
has 6 rows and cols, it will fill the range of cells from "A1" to "E6".
When we try to do the same, by making a call from Menu Item (Addin
adds a new Menu Item in Excel menus ) the call succeeds and the data
has been displayed properly .

However if we specify the same formula in one of the cell (press
F2,insert the formula, press CTRL + SHIFT + ENTER to calculate)as soon
as the code updates one of the cells,the Exception returned is

Exception from HRESULT: 0x800A03EC.


Please suggest.

Code Snippet :-
--------------

_oExcelRange = (Excel.Range) _oExcelApp.ActiveCell;
if (m_oDtrsData.Length 0)
{
for (int _iDataRowIndex=0; _iDataRowIndex <
m_oDtrsData.Length;_iDataRowIndex++)
{
int _iColCount = 0;
foreach(DataColumn _oDataColumn in m_oDtColumns)
{
if(_oDataColumn.DataType ==
Type.GetType("System.DateTime"))
{

_oExcelRange.get_Offset(_iDataRowIndex,_iColCount) .Value2 =
Convert.ToDateTime(m_oDtrsData[_iDataRowIndex][_oDataColumn].ToString());
}
else
if(Utilities.IsNumeric(m_oDtrsData[_iDataRowIndex][_oDataColumn].ToString()))
{

_oExcelRange.get_Offset(_iDataRowIndex,_iColCount) .Value2 =
Convert.ToDouble(m_oDtrsData[_iDataRowIndex][_oDataColumn].ToString());
}
else
{

_oExcelRange.get_Offset(_iDataRowIndex,_iColCount) .Value2 =
m_oDtrsData[_iDataRowIndex][_oDataColumn];
}
_iColCount = _iColCount + 1;
}
}
}

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Setting Excel Cell values using C#

Can this be due to the Limit imposed by Excel for worksheet formula.
Basically the limit is that the worksheet formula can only return a
value to the cell containing the formula. Other attributes of the cell
cannot be changed (formatting etc) and no other cell can be modified.
Can any of you Gurus can confirm the same ????

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting cell values based on a 3rd cell Bob Excel Worksheet Functions 4 March 30th 10 08:53 PM
Dynamically setting CELL COLORS based on TWO OTHER cell values Tom Excel Discussion (Misc queries) 3 February 22nd 09 07:34 PM
Setting values in a cell Stephen Excel Discussion (Misc queries) 3 July 10th 08 08:23 PM
Need assist with setting cell values from an addin subroutine [email protected] Excel Programming 1 December 12th 04 01:52 PM
Setting SeriesCollection values in Excel 2000 nubee Excel Programming 4 May 29th 04 03:08 AM


All times are GMT +1. The time now is 09:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"