Is it possible for us to update/reuse the existing excel workbook/worksheet using dynamics NAV without creating a new workbook every time ??
By following the below mentioned prototype we were able to achieve the solution
- Open the excel file by specifying the file path.
- Specify the excel sheet name.
- Clear the already existing contents.
- Export the values in the same worksheet
The following code drives the above steps:
//xlapp – Automation – Microsoft Excel 12.0 Object Library. Application
//xlbook – Automation – Microsoft Excel 12.0 Object Library. Workbook
//xlsheet – Automation – Microsoft Excel 12.0 Object Library. WorkSheet
//filepath – Text [1024]
Filepath:=’’; //1. Specify the location where the excel file is stored locally
IF ISCLEAR(xlapp) THEN
CREATE(xlapp);
xlapp.visible(true);
//1. Opening the excel file
xlbook:=xlapp.Workbooks.Open(filepath);//2. specify your file path with the filename.xls(x)
For complete information follow the link specified below
http://congruentdynamics.blogspot.in/2013/05/updating-existing-worksheet-in.html