AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.09.2017, 14:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
saurav-nav: How To Report SaveAsHTML Pre NAV 2017.
Источник: http://saurav-nav.blogspot.com/2017/...-nav-2017.html
==============

Hi Readers,

Origin of the today's post is a requirement to Save as Report as HTML in NAV 2016. This also brings some learnings for me so thought to share with you all.

Till NAV 2009 (if I remember it correctly) Report.SaveAsHTML was supported but due to design changes in NAV Microsoft decided to obsolete this feature after NAV 2009. But later in NAV 2017, microsoft felt a need to the function and it came back in existence.

But due to this confusion, I have provided a bad estimate and end-up spending good amount of time to translate a report (in my case word layout) to an HTML file.

In this article, we will see how we can transform a word file to an HTML File using DOTNET Components.



** This article applies to NAV 2013, NAV 2013 R2, NAV 2015 and NAV 2016 as SaveasHTML exist in NAV 2017.

** Code in the article is to save HTML file as user defined location in the client. If you need to save in server, change DOTNET variable of RunOnClient = NO and set file path and Name instead of a popup.

For the demo, i will be using a SaveasWord Feature to make it simple but you can also use word layout with same code base in your need.

I am planning to keep all DOTNET re-writes in the same Codeunit that it can be used whenever required.

Create a New Function - SaveReportAsHTML which input a Variant Record that needs to be printed.
The Function Creates -

1. Two Temp files of Word and HTML extensions to be used in the process later.
2. Get Report ID using Report selection & Save Report as Word.
3. Open Word File using DOTNET, Save as HTML and Save File in Temp Path.
4. Ask User for File Path and Move File from Temp to the User Defined Path.

Dotnet Variables used in function -

WordApplication - Microsoft.Office.Interop.Word.ApplicationClass.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

WordDocument - Microsoft.Office.Interop.Word.Document.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

WordHelper - Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.'Microsoft.Dynamics.Nav.Integration.Office, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

WordSaveFormat - Microsoft.Office.Interop.Word.WdSaveFormat.'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

All Code used for these four tasks is below.


* You can extend Part two (Case Statement) as per your requirement. Report Code will remain same.

Almost Done. Let's do calling from Sales Invoice Page.

Add an action in Page and Call the function that we wrote above, as shown below.


Let's Run.


Share your thoughts about it. I have so many rewrites where I use Dotnet to get performance or only option to rewrite in new versions. If you have a scenario that we can discuss in future articles please put also that as the comment.

If you want to use the code, please download an object from the on-drive.
File Name - Microsoft Dynamics NAV -#SauravNav_Dotnet_Functions_Codeunit_50000

Please share your views. Happy to hear all of them !! Stay connected will be back soon.

Regards,
Saurav Dhyani
saurav-nav.blogspot.in


Источник: http://saurav-nav.blogspot.com/2017/...-nav-2017.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
german_nav_developer: Catch Me If You Can – try-catch für .NET in C/AL Blog bot Dynamics CRM: Blogs 0 22.09.2014 11:00
Platform updates overview - 3.70.B - NAV2009 R2 Blog bot Dynamics CRM: Blogs 0 07.02.2011 22:06
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2009 SP1 Blog bot Dynamics CRM: Blogs 0 11.06.2010 16:33
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2009 Blog bot Dynamics CRM: Blogs 0 04.06.2010 13:21
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:07.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.