I'm having a big problem porting C# code to C++ code. I'm trying to save all my datagridview
info into an Excel file but it's giving me a lot of errors. These are my 2 headers and I already added the interop dll. I'm just having problems cause I've found a lot of C# info but not C++ and I'm still a student.
using namespace Microsoft::Office::Interop::Excel;
#define Excel Microsoft::Office::Interop::Excel
// Here is the button:
Excel::Application^ xlApp =gcnew Excel::ApplicationClass();
Excel::Workbook^ xlWorkBook=xlApp->Workbooks->Add(Type::Missing);
Excel::Worksheet xlWorkSheet =(Excel::Worksheet)xlWorkBook::Worksheets->get_Item(1);
object misValue = System->Reflection->Missing->Value;
int i = 0;
int j = 0;
for (i = 0; i <= DGV_ComprasUsuarios->RowCount - 1; i++)
{
for (j = 0; j <= DGV_ComprasUsuarios->ColumnCount - 1; j++)
{
DataGridViewCell cell = DGV_ComprasUsuarios[j, i];
xlWorkSheet.Cells[i + 1, j + 1] = cell->Value;
}
}
xlWorkBook::SaveAs("csharp.net-informations.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook::Close(true, misValue, misValue);
xlApp::Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
MessageBox.Show("Excel file created , you can find the file c:\\csharp.net-informations.xls");