问题描述
我正在vc ++和C#中开发应用程序.我的应用程序可以从excel文件(2003、2007和2010)导入,以便与我正在使用Interop程序集的excel通信.我可以从excel导入,也可以转移到Excel.我的问题是,当用户更改应用程序中的值并且将其导出回示例excel文件时,而不是添加为新记录时,它应该从其导入位置更新行.
例如:
我有一个Excel文件名"test.xls",其中包含100行数据,并且此Excel文件已导入到我的应用程序中.用户正在更新第十行中的值,并导出回相同的test.xls.目前,第10行数据将作为新行添加,即101,我期望的是代替新行添加,它应该可以修改或更新第10行.
有人可以给我示例代码来做到这一点吗.
编程环境
前端:vc ++ mfc
与Excel进行通讯的后端:C#
谢谢
Subbu
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
推荐答案
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
这篇关于使用互操作程序集从Excel导入和导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!