Excel Buffer - Deleting Rows

Jonathan2708
Member Posts: 552
Hi,
I'm using the Excel Buffer to create a report in Excel and want to delete some rows that may have been created before sending to Excel. I had an issue with this so created a test app to examine. Look at the following code :
This code successfully creates an Excel sheet with 100 rows and 5 columns populated. Now say I want to delete row 50 before outputting to Excel - I add the following 3 lines immediately prior to the CreateBook() call :
When this is run the Excel sheet opens but with no cells populated at all. If I change the tmptblExcelBuffer variable to a non-temporary variable so I can see the rows created I see that all the rows are present except for row 50.
Any ideas what's happening here? Don't ask me why I don't just skip row 50 in the loop - the example is just to demonstrate this behaviour.
Thanks
Jonathan
I'm using the Excel Buffer to create a report in Excel and want to delete some rows that may have been created before sending to Excel. I had an issue with this so created a test app to examine. Look at the following code :
FOR intRowNumber := 1 TO 100 DO BEGIN FOR intColNumber := 1 TO 5 DO BEGIN tmptblExcelBuffer.INIT; tmptblExcelBuffer.VALIDATE("Row No.", intRowNumber); tmptblExcelBuffer.VALIDATE("Column No.", intColNumber); tmptblExcelBuffer."Cell Value as Text" := FORMAT(intRowNumber) + ' x ' + FORMAT(intColNumber); tmptblExcelBuffer.INSERT(TRUE); END; END; tmptblExcelBuffer.CreateBook(); tmptblExcelBuffer.CreateSheet('Excel Report 2', 'Excel Report 2', COMPANYNAME(), USERID()); tmptblExcelBuffer.GiveUserControl();
This code successfully creates an Excel sheet with 100 rows and 5 columns populated. Now say I want to delete row 50 before outputting to Excel - I add the following 3 lines immediately prior to the CreateBook() call :
tmptblExcelBuffer.RESET; tmptblExcelBuffer.SETRANGE("Row No.", 50); tmptblExcelBuffer.DELETEALL(TRUE);
When this is run the Excel sheet opens but with no cells populated at all. If I change the tmptblExcelBuffer variable to a non-temporary variable so I can see the rows created I see that all the rows are present except for row 50.
Any ideas what's happening here? Don't ask me why I don't just skip row 50 in the loop - the example is just to demonstrate this behaviour.
Thanks
Jonathan
0
Answers
-
Forget it, always answer my own questions after posting!
Obviously I needed to perform a tmptblExcelBuffer.RESET; before running the CreateBook() in order to clear the filter used for the delete.
Jonathan0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions