Change Worksheet in exiting Excel-File

Martin_Förster
Member Posts: 55
Hallo,
my Problem is really specific. All Topica wich I found to deal with Export Data to a new Excel File.
My Problems are that I Have to export Data in a exiting Ecxel File with more than 1 Worksheet.
I can open the file an write data in the first Worksheet but when i try to change the worksheet and write Data, Navision write this data in the first worksheet.
Can somebody help me.
Here are my code:
thanks fpor your help.
Martin
my Problem is really specific. All Topica wich I found to deal with Export Data to a new Excel File.
My Problems are that I Have to export Data in a exiting Ecxel File with more than 1 Worksheet.
I can open the file an write data in the first Worksheet but when i try to change the worksheet and write Data, Navision write this data in the first worksheet.
Can somebody help me.
Here are my code:
CREATE(EXCLAPP); ExclWorkbook := ExclApp.Workbooks.OPEN('C:\schnittstelle.xls'); //ExclApp.ActiveWorkbook.Sheets.Select(1); Exclworksheet := ExclApp.ActiveSheet; ExclWorksheet.Select(1); ExcelZeile := '2'; ExclWorksheet.Range('C' + ExcelZeile).Value := '000001'; ExcelZeile := '3'; ExclWorksheet.Range('C' + ExcelZeile).Value := FORMAT(TODAY); ExcelZeile := '4'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxxxxxx'; ExcelZeile := '5'; ExclWorksheet.Range('C' + ExcelZeile).Value := ''; ExcelZeile := '6'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxxxxxx'; ExcelZeile := '7'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxxxx'; ExcelZeile := '8'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxxxxxxxxx'; ExcelZeile := '9'; ExclWorksheet.Range('C' + ExcelZeile).Value := '123123123'; ExclWorksheet.Select(2); ExcelZeile := '3'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'test'; ExclApp.Visible := TRUE;[/b]
thanks fpor your help.
Martin
0
Comments
-
To add a sheet:
XlWrkSht := XlWrkBk.Worksheets.Add; XlWrkSht.Name(SheetName);
To Delete:XlWrkSht := XlWrkBk.Worksheets.Item(SheetNumber); XlWrkSht.Delete;
SheetNumber - integer
I hope taht helpsBest Regards,
Oleg0 -
Okay that's right!!!!
IT workS!!!! :-)
For these People who have the Same Problems here Are the Code:CREATE(ExclApp); ExclWorkbook := ExclApp.Workbooks.Open('C:\schnittstelle.xls'); ExclWorksheet := ExclWorkbook.Worksheets.ITEM('Kopfdaten'); ExcelZeile := '2'; ExclWorksheet.Range('C' + ExcelZeile).Value := '000001'; ExcelZeile := '3'; ExclWorksheet.Range('C' + ExcelZeile).Value := FORMAT(TODAY); ExcelZeile := '4'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxx'; ExcelZeile := '5'; ExclWorksheet.Range('C' + ExcelZeile).Value := ''; ExcelZeile := '6'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxx'; ExcelZeile := '7'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxx'; ExcelZeile := '8'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxx'; ExcelZeile := '9'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'xxxx'; ExclWorksheet := ExclWorkbook.Worksheets.ITEM('Debitorenstammdaten'); ExcelZeile := '3'; ExclWorksheet.Range('C' + ExcelZeile).Value := 'test'; ExclApp.Visible := TRUE;
Explain:
First the report open the exiting Excel File, then it looks for the Worksheet called 'Kopfdaten'. Next I fill these cells which want to get the Information :-).
Atfer That I Called the next Worksheet named 'Debitorstammdaten'.
And so one...
Really nice these Procedure....
THX
MArtin0
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