Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi ,

I am developing an application in vc++ and C# . My Application can import from an excel file (2003,2007 & 2010 ) , for communicating with excel I am using Interop Assemblies . I am able to Import from excel and I am able to transfer to Excel . My Problem is when the user is changing the value in my application and when he is exporting it back to sample excel file instead of adding as a new record it should update the row from where it was imported .

For Example :

I am having a Excel File name "test.xls" which has 100 rows of data and this Excel file is imported to my application . User is updating the values in 10th Row and exporting back to same test.xls . At present this 10th row data will added as new row ie 101 , what I am expecting is instead of adding as new row, it Should modify or update the row 10 is this possible .

Can some one give me sample codes to do this .

Programming environment

Front End : vc++ mfc

Back end for Communicating with Excel : C#

Thanks

Subbu
Posted

1 solution

If you are using Datagridview to insert , display and update rows means,
Get the datagridview updated row number and Add 1 . Update the particular row in Excel

int Datagridviewupdatedrow = DataGridViewRowUpdated + 1 

 WorkSheetApp.Cells[Datagridviewupdatedrow, 1] = cell_value_1;
 WorkSheetApp.Cells[Datagridviewupdatedrow, 2] = cell_value_2;
 WorkSheetApp.Cells[Datagridviewupdatedrow, 3] = cell_value_3;


If you give a part of code , then will be helpful to explain more.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900