I am converting a MFC C++ COM Addin to a VSTO Excel Addin in C# .NET4.0. There is a lot of code referring to the C API in it. Here is an example. I am possibly going to use Excel DNA to simplify my conversion task.
FYI: xlr is a class in the XLSDK.
//allocate local storage for the reference
m_pControllerReference = new xlr( controllerRange ) ;
//get the name of the book and sheet with the reference
g->Excel.fn( xlSheetNm, *m_pControllerReference ) ;
if ( g->Excel.resultXltype() != xltypeErr )
{
m_referenceSheetName = g->Excel.resultCString() ;
// and get the sheet ID
g->Excel.fn( xlSheetId, xl(m_referenceSheetName) ) ;
if ( g->Excel.resultXltype() != xltypeErr )
{
m_controllerSheetId = g->Excel.resultSheetId() ;
xlr theRange( m_pControllerReference->GetLPXLOPER(),
0, TRUE ) ;
if(theRange.nRows() >6)
........etc
Does this convert like this?
m_pControllerReference = (Excel.Range)controllerRange;
m_referenceSheetName =
(string)XlCall.Excel(XlCall.xlSheetNm, m_pControllerReference );
m_controllerSheetId = XlCall.Excel(XlCall.xlSheetId,
m_referenceSheetName); // and get the sheet ID
//how to convert this ?
//xlr theRange( m_pControllerReference->GetLPXLOPER(),
0, TRUE ) ;
Or is there a better way of converting without resorting to a 3rd party utility? Can I do everything in VSTO? Is there a chart somewhere of C API to C# conversions?