ExcelBuf Record Excel Buffer(370) Temporary=Yes DataItem Name --------- ------------------ G/L Entry PurchaseDocuments G/L Entry ChequesPettyCash PurchaseDocuments - OnPreDataItem() ----------------------------------- ExcelBuf.NewRow; ExcelBuf.AddColumn('PurchInvNo.',FALSE,'',TRUE,FALSE,TRUE,'@'); PurchaseDocuments - OnAfterGetRecord() -------------------------------------- ExcelBuf.NewRow; ExcelBuf.AddColumn("Document No.",FALSE,'',FALSE,FALSE,FALSE,''); PurchaseDocuments - OnPostDataItem() ------------------------------------ ExcelBuf.CreateBook; ExcelBuf.CreateSheet('PurchDocs','PurchDocs',COMPANYNAME(),USERID()); ExcelBuf.DELETEALL(FALSE); ChequesPettyCash - OnPreDataItem() ---------------------------------- ExcelBuf.NewRow; ExcelBuf.AddColumn('ChequesNo.',FALSE,'',TRUE,FALSE,TRUE,'@'); ChequesPettyCash - OnAfterGetRecord() ------------------------------------- ExcelBuf.NewRow; ExcelBuf.AddColumn("Document No.",FALSE,'',FALSE,FALSE,FALSE,''); ChequesPettyCash - OnPostDataItem() ----------------------------------- ExcelBuf.CreateSheet('Cheques','Cheques',COMPANYNAME(),USERID()); Report - OnPostReport() ----------------------- ExcelBuf.GiveUserControl;
Comments
Which sheet ends up being created?
Tino Ruijs
Microsoft Dynamics NAV specialist
No my understanding is that you call CreateSheet once you have populated the buffer records. The sheet being created is the one for the second dataitem - 'Cheques'.
Jonathan
i dealt with the same problem about 4 years ago and i can remember, that the main problem of this is the wrong key in the table excel buffer.
When you check the fields available in T370, you'll notice that there is nothing such as "Worksheet", which means you could only enter the data for one worksheet at runtime.
It takes some effort to expand the table with a new field "WORKSHEET", expand the key and also adjust the Code saved in Table 370.
Best regards
Bluegene
ExcelBuf.SetUseInfoSheed;
Before ExcelBuf.CreateBook;
?
I have the same question.
The CreateSheet function uses the active worksheet. It expects the worksheet to already exist. This is why it works for 1 worksheet. A new workbook gets created with 1 worksheet to start. To build multiple worksheets you must add a new worksheet before you call the CreateSheet function each time. CreateSheet does not create a worksheet. It adds data to the existing active sheet.
AddSheet()
XlWrkBk := XlApp.ActiveWorkbook;
XlWrkSht := XlWrkBk.Worksheets.Add;
I have done something similar in 4.3 using table 370, I already have the Addworksheet function (works ok) and the extra field on table 370 with a change to the primary key (works ok too), so far so good!!!
The problem I am having is getting the values from the buffer table to appear on the correct sheet. ](*,)
Any suggestions ?
TIA.
Dean.
:idea: I'VE GOT IT !!!! (Finally LOL \:D/ )
The solution was staring me in the face all the time... so here goes
Step 1:
Add a new field to the buffer table (370): Step 2:
Change the primary key to include your new field.
Step 3:
Create a new function in the buffer table
Et Voila
No????? #-o
Hanen TALBI
I have added the AddSheet function to T 370 but when I call the function am I getting the following
massage:
Any help would be appreciated
Hanen TALBI
Hello @bbrown. Do you know how can I use your function with DotNet variables xlWrkBkDotNet and XlWrkShtDotNet? since there is no dotnet xlApp etc.?