As i’ve wrote in the tittle, I need to export a item list to excel in NAV 2018. In 2013, I was doing it with a report, defined as shown below:
CodeUnit code calling to the report:
ServerDestination := 'C:\Users\Public\Documents\insizeStock\';
Tofile := STRSUBSTNO('InsizeEUR.xlsx');
REPORT.SAVEASEXCEL(50070,ServerDestination + Tofile);
“Item” dataitem properties:
When I run the method from the Codeunit, The excel is created, but it is empty. Is it possible to create a escel with a report in NAV2018, or should I create it with an XMLPort??
Thank you very much
You can use the ExcelBuf and create a simple report to export transactions from Item table to excel. Check Aged accounts receivable report or Aged payable report and you will see an example how they send it to excel.
Is it the same report as in NAV 2013? What happens if you run it “normally”, does it create the data as they are supposed to?
One alternative is, as sbhatbng writes to program it with the ExcelBuffer table/functionality. That gives you a bit more “control” over how the Excel file is going to look, but if the requirement aren’t bigger than what you show in your post, then that should not be required.
Another alternative would be to create the same report as a list page, then just open it with Excel.
First of all, thank you both for your answers. I will try to explain the whole process, to help you to understand what I was doing in NAV2013 and what I need to do in NAV2018
The main goal of this development, is to download an excel file with the inventories of items from a location, and then, send that excel with a FTP program to a webSite. First of all, I’ve created an .exe program with VisualStudio, that call to the shown codeUnit. This exe file is run from the task planner in the server. After creating the excel, I run another task from the task planner, that sends the excel file via FTP All this is working perfectly in NAV2013.
The excel file looks like this in NAV2013:
Answering yo tour question [mention:61b2aa9ce72e429baa1ef43208ddbea4:e9ed411860ed4f2ba0265705b8793d05], yes, the reports are exactly the same in NAV2013 and NAV2018, I’ve import them directly. What do you mean with "running normally?
I will take a llok to the reports that [mention:e8a9b4a4c12f4558a4b4428326a620b2:e9ed411860ed4f2ba0265705b8793d05] talk about, but, i think this issue is quite simple, and should work same way as in NAV2013, am I worng?
Thank you again, really appreciated your answers!
I mean if you are able to print the report to the screen or a printer? You should always start by test that. Technically there should not be any differences, as long as you have upgraded the report as every other report.
I’ve just import again the reports from NAV2013 to NAV2018, and still working same way, the result is empty. If I do “Run” in th report from the object designer, the same…
“The same” as in when you print the report in NAV 2018 (without SAVEASEXCEL), then you don’t get any data?
If that is the case, then your error has nothing to do with the SAVEASEXCEL functionality. If the report does not print any data, then nothing will be saved to Excel.
So you should go back and find out why the report does not produce any data in NAV 2018.
I’ve created a button, to call the codeUnit’s method. In that way, I can put a breakpoint, so I can debug and follow the session. It looks it is traveling through the items, but not writting them in the excel…
But what happens when you print it to a printer (or preview)? Does it work or not? Don’t even start testing SaveToExcel, before the report works otherwise.
OMG… Thank you for your tips Erik, this is really surprising.
When importing the report from 2013 to 2018, the table from the layout has dissapeared… I realised of that when you told to do the preview.
I’m really stoked…
Thank you again Erik, your help is really appreciated!!!
Happy that I could help. When you find out why the layout has disappeared, then please let us know. If you had been saying it was a report in NAV 2009, then I may have understood it, but I don’t understand what could have gone wrong when upgrading from NAV 2013 to NAV 2018, that could have caused it.
You also better check if it happened with other reports from NAV 2013 too.
Previously, I made an upgrasde from 2009 to 2013 with another customer, and I know that there is a special process to upgrade the reports passing through the 2013 version. But as you know, this is not the case.
May be could be that in 2013 they were designed in VS, and know in the report builder… I don’t know, I’ll work on it to see if I find the answer. Anyway, I also hope that no other report ahs lost its layout…
Thank you again!!!
Otherwise, if you still have a copy of the NAV 2013 database, and the layout is actually there, if it is, then export and then import it to the NAV 2018 database again again. Eventually as a text file.
The server with 2013 is still available. I’ve exported the report, both in txt and fob, and imported on 2018, and the same result in both scenarios… The table from the layout, has dissapeared.
Really extrange, and has I’m seeing, this isn’t happening with all the reports that have been upgraded…
Did you check that the report still works in NAV 2013, that you were able to open the RDLC layout with Visual Studio, before you exported the report? And did you check if the text file actually contains the RDLC layout before you imported it? You can upload the text file here, if you like, then maybe I can see if something is wrong there (just drop the text file to the reply area).