我在 C#.NET4.0转换MFC C++ COM加载项的VSTO Excel加载项。有很多代码指的是C API。 这里是一个例子。我可能会使用Excel DNA来简化我的 转换任务。代码转换 - MFC C++到VSTO Excel加载项在C#
供参考:xlr是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
这样转换吗?
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) ;
还是有没有更好的方式转换而不诉诸第三方实用程序?我能做VSTO的一切吗? C API到C#转换中是否有图表?
class xlr派生自xl0,派生自CObject。\t xlr(LPXLOPER xltypeRef_lpxloper,int idx,BOOL readData = FALSE); //通过一个不相交的索引的单个范围参考(通过一个基于零的索引) //可选择读取 – 2012-03-29 12:40:49
中的数据好吧,它似乎包装了一个xltypeRef类型的XLOPER,因此ExcelReference将成为Excel-DNA的对应物。 – Govert 2012-03-29 12:54:49