Export to Excel using ExcelBuffer

zeon
Member Posts: 130
Hi,
I have an existing Excel file containing five worksheets. I need to export data from Navision to one of those worksheets.
The sheet already contains data, so I need a way to clear the sheet before I make my export. Is there a way to do that or delete an entire sheet, or do I have to run through all columns and rows with data and delete their contents? I'm using Excelbuffer to export the data.
I have tried to just update the sheet with new data, but the problem is that in one situation the export is 500 rows, and the data contains data in 1000 rows, so the last 500 rows is not deleted.
/zeon
I have an existing Excel file containing five worksheets. I need to export data from Navision to one of those worksheets.
The sheet already contains data, so I need a way to clear the sheet before I make my export. Is there a way to do that or delete an entire sheet, or do I have to run through all columns and rows with data and delete their contents? I'm using Excelbuffer to export the data.
I have tried to just update the sheet with new data, but the problem is that in one situation the export is 500 rows, and the data contains data in 1000 rows, so the last 500 rows is not deleted.
/zeon
0
Answers
-
I would think the easiest way is to delete the Sheet and then recreate it.
I looked at the Excel Automation and cannot see a clear all.
You probably could do it by defining a range variable that includes the whole sheet and then clear that way but pretty convoluted.Apathy is on the rise but nobody seems to care.0 -
Ok, if I use the Excel Automation and then delete the sheet the user is prompted with the message that the sheet possibly contains data and if the user wants to delete the data.
Can I avoid that message, so that no user interaction is needed?
Another question - is it possible to get the row number returned of the last row which contains data?
/zeon0 -
I solved the problem. In stead of deleting the sheet and the create a new one, it is easier to just clear the sheet before export.
xlRange := xlWorksheet.Range('A1:G65536');
// 65536 is max. no of cells in Excel (2003). I only needed to clear in the range from A->G-cell.
xlRange.Clear;
/zeon0
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