目前我有以下代码:
int ExportToExcel(short *data, int nof_rows, int nof_cols)
{
HRESULT hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hr))
{
cout << "Failed to initialize COM library. Error code = 0x" << hex << hr << endl;
return hr;
}
Excel::_ApplicationPtr pXL;
if ( FAILED( pXL.CreateInstance( "Excel.Application" ) ) )
{
cout << "Failed to initialize Excel::_Application!" << endl;
return -1;
}
Excel::_WorkbookPtr workbook = pXL->Workbooks->Add(Excel::xlWorksheet);
Excel::_WorksheetPtr pSheet= pXL->ActiveSheet;
pSheet->Name = "arr_1";
Excel::RangePtr pRange = pSheet->Cells;
for(int i=1; i<=nof_rows; i++)
for(int j=1;j<=nof_cols; j++)
pRange->Item[i][j] = *data++;
pXL->Visible=true;
return 0;
}
但是上面的实现恰好很慢..
任何想法如何以更有效的方式倾倒阵列?