Excel once again: How to create multiple sheets ?

Nokio
Member Posts: 52
Hi,
i have the following problem. I've created an extern Excel file which i have to fill out from navision later. I will make this with the ExcelBuffer table.
It has the standard 3 worksheets and I need 3 worksheets more.
How exactly i can create them?
I have the folling automations. Do I need any others?
Excel = 'Microsoft Excel 11.0 Object Library'.Application
Workbook ='Microsoft Excel 11.0 Object Library'.Workbook
Worksheet = 'Microsoft Excel 11.0 Object Library'.Worksheet
Another Question is, when I manage to create the 3 worksheets, how can I select f.e. sheet no. 4.
Couldn't find anything helpful in searching the forum.
Thx 4 any help.
i have the following problem. I've created an extern Excel file which i have to fill out from navision later. I will make this with the ExcelBuffer table.
It has the standard 3 worksheets and I need 3 worksheets more.
How exactly i can create them?
I have the folling automations. Do I need any others?
Excel = 'Microsoft Excel 11.0 Object Library'.Application
Workbook ='Microsoft Excel 11.0 Object Library'.Workbook
Worksheet = 'Microsoft Excel 11.0 Object Library'.Worksheet
Another Question is, when I manage to create the 3 worksheets, how can I select f.e. sheet no. 4.
Couldn't find anything helpful in searching the forum.
Thx 4 any help.
0
Comments
-
There's no way to create multiple sheets with ExcelBuffer... I've created a new object based on Excel Buffer with these these updates :
1) I've modified the function "CreateSheet" in a way it always call the automation server function that adds a sheet.
2) I've created one function called "FillDataInSheet(SheetName)" with the following code :
CreateSheet(SheetName,'xxxx',COMPANYNAME,USERID);
DELETEALL;
ClearNewRow;
When i want to export in excel from any other object :
1) First i create a variabile linking to the new object
2) I call AddColumn...
3) I call FillDataInSheet. It fills the sheet and make the buffer empty.
4) Start over again from 2 for every sheet you want to create.
Bye0 -
Which function of the automation server is´it and how exactly can I use it?0
-
This is the function i've modified...in bold the function of automation server.
Open table 370 and compares the code to mine.
Note that I've deleted any refernce to the "Information Sheet" of the standard because i use it as any other sheet (I deleted also the functions addinfocolumns....).
CreateSheet(SheetName : Text[250];ReportHeader : Text[80];CompanyName : Text[30];UserID2 : Text[30])
Window.OPEN(
Text005 +
'@\');
Window.UPDATE(1,0);
XlEdgeBottom := 9;
XlContinuous := 1;
XlLineStyleNone := -4142;
XlLandscape := 2;
CRLF := 10;
RecNo := 1;
TotalRecNo := COUNTAPPROX + InfoExcelBuf.COUNTAPPROX;
RecNo := 0;
XlWrkSht := XlWrkBk.Worksheets.Add();
XlWrkSht.Name := SheetName;
IF ReportHeader <> '' THEN
XlWrkSht.PageSetup.LeftHeader :=
STRSUBSTNO('%1%2%1%3%4',GetExcelReference(1),ReportHeader,CRLF,CompanyName);
XlWrkSht.PageSetup.RightHeader :=
STRSUBSTNO(Text006,GetExcelReference(2),GetExcelReference(3),CRLF,UserID2);
XlWrkSht.PageSetup.Orientation := XlLandscape;
IF FIND('-') THEN BEGIN
REPEAT
RecNo := RecNo + 1;
Window.UPDATE(1,ROUND(RecNo / TotalRecNo * 10000,1));
IF NumberFormat <> '' THEN
XlWrkSht.Range(xlColID + xlRowID).NumberFormat := NumberFormat;
IF Formula = '' THEN
XlWrkSht.Range(xlColID + xlRowID).Value := "Cell Value as Text"
ELSE
XlWrkSht.Range(xlColID + xlRowID).Formula := GetFormula;
IF Comment <> '' THEN
XlWrkSht.Range(xlColID + xlRowID).AddComment := Comment;
IF Bold THEN
XlWrkSht.Range(xlColID + xlRowID).Font.Bold := Bold;
IF Italic THEN
XlWrkSht.Range(xlColID + xlRowID).Font.Italic := Italic;
XlWrkSht.Range(xlColID + xlRowID).Borders.LineStyle := XlLineStyleNone;
IF Underline THEN
XlWrkSht.Range(xlColID + xlRowID).Borders.Item(XlEdgeBottom).LineStyle := XlContinuous;
UNTIL NEXT = 0;
XlWrkSht.Range(GetExcelReference(5) + ':' + xlColID + xlRowID).Columns.AutoFit;
END;
Window.CLOSE;0 -
Great info!, thanksTecSA Malaysia
Those of you who think you know everything are annoying to those of us who do. -
David Brent0 -
Nokio wrote:It has the standard 3 worksheets and I need 3 worksheets more.
FYI
Excel->Tools->Options->General->"Sheets In New Workbook"=3
you can change it to whatever you want.0
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