Excel Import XLSX (read only lines in filter) - NAV 2013 R2

robertwendler@yahoo.de
Member Posts: 27
Hi guys,
every week we get a big excel file. We import all values into NAV with excel buffer and process the data. Unfortunately the excel file has a filter.
For example: The excel file has 1000 lines and 200 are in the current filter. We want to import only the 200 lines in the filter.
We get the file with the filter and the sender will not change the excel file.
Is there any chance to automate this process? At the moment we copy the filtered lines to a new sheet and import this sheet.
every week we get a big excel file. We import all values into NAV with excel buffer and process the data. Unfortunately the excel file has a filter.
For example: The excel file has 1000 lines and 200 are in the current filter. We want to import only the 200 lines in the filter.
We get the file with the filter and the sender will not change the excel file.
Is there any chance to automate this process? At the moment we copy the filtered lines to a new sheet and import this sheet.
0
Best Answers
-
Hi,
You can get the list of hidden rows by the following way:
Add the function below to Excel Buffer table:PROCEDURE GetHiddenRowsList(VAR RowsList : TEMPORARY Record Integer); ---------- XMLDOMManagement : Codeunit XML DOM Management; XmlWrkShtDoc : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument"; XmlNodeList : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"; XmlNode : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlElement"; XmlNamespaceManager : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNamespaceManager"; RowNo : Integer; ---------- RowsList.RESET; RowsList.DELETEALL; XmlWrkShtDoc := XmlWrkShtDoc.XmlDocument; XmlWrkShtDoc.LoadXml(XlWrkShtReader.Worksheet.OuterXml); XMLDOMManagement.AddNamespaces(XmlNamespaceManager,XmlWrkShtDoc); XmlNodeList := XmlWrkShtDoc.SelectNodes('/x:worksheet/x:sheetData/x:row[@hidden=1]',XmlNamespaceManager); IF ISNULL(XmlNodeList) THEN EXIT; FOREACH XmlNode IN XmlNodeList DO BEGIN EVALUATE(RowNo, XmlNode.GetAttribute('r')); RowsList.Number := RowNo; RowsList.INSERT; END;
And then you can check whether the row hidden or not and use only data from visible rows:LOCAL PROCEDURE OpenXlAndGetHiddenRows(); ---------- xlBuf : TEMPORARY Record Excel Buffer; HiddenRowsList : TEMPORARY Record Integer; FileManagement : Codeunit File Management; ClientFileName : Text; ServerFileName : Text; SheetName : Text; ---------- xlBuf.RESET; xlBuf.DELETEALL; ClientFileName := FileManagement.OpenFileDialog('','',FileManagement.GetToFilterText('','*.xlsx')); IF ClientFileName = '' THEN EXIT; ServerFileName := FileManagement.UploadFileSilent(ClientFileName); SheetName := xlBuf.SelectSheetsName(ServerFileName); xlBuf.OpenBook(ServerFileName,SheetName); xlBuf.GetHiddenRowsList(HiddenRowsList); xlBuf.ReadSheet; IF xlBuf.FINDLAST THEN BEGIN MESSAGE('%1 of %2 rows are visible', xlBuf."Row No."- HiddenRowsList.COUNT, xlBuf."Row No."); IF HiddenRowsList.GET(xlBuf."Row No.") THEN MESSAGE('The last row is hidden') ELSE MESSAGE('The last row is visible'); END;
This is solution for Nav 2017, but I think can be used in Nav 2013.1 -
Just to let you guys know: FOREACH is not supported in NAV 2015 or older.
Other Solution:Name DataType Subtype Length Enumerator_l DotNet System.Collections.Generic.List`1+Enumerator.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Enumerator_l := XmlNodeList_l.GetEnumerator; WHILE Enumerator_l.MoveNext DO BEGIN XmlNode_l := Enumerator_l.Current; EVALUATE(RowNo_l, XmlNode_l.GetAttribute('r')); RowsListTmp_v.Number := RowNo_l; RowsListTmp_v.INSERT; END;
Also you have to downgrade the function AddNamespaces in the XMLDOMManagement.0
Answers
-
This looks nice. I will try this. Thanks!0
-
Why was the post with the solution deleted?0
-
[Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
Probably the poster deleted it for some reason. I've seen also people deleting their questions after it has been answered. Still don't know why they do it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
@kriki There is no option on Mibuso to delete own comment, or is there? I wanted to delete my comment once, and could not find any way to do so.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
mibuso.com https://forum.mibuso.com/
AlexDen answered your question: Excel Import XLSX (read only lines in filter) - NAV 2013 R2
Check it out: https://forum.mibuso.com/discussion/comment/325659#Comment_325659
I have seen the complete solution to my problem and then the post was deleted?!
0 -
Hi,
You can get the list of hidden rows by the following way:
Add the function below to Excel Buffer table:PROCEDURE GetHiddenRowsList(VAR RowsList : TEMPORARY Record Integer); ---------- XMLDOMManagement : Codeunit XML DOM Management; XmlWrkShtDoc : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument"; XmlNodeList : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"; XmlNode : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlElement"; XmlNamespaceManager : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNamespaceManager"; RowNo : Integer; ---------- RowsList.RESET; RowsList.DELETEALL; XmlWrkShtDoc := XmlWrkShtDoc.XmlDocument; XmlWrkShtDoc.LoadXml(XlWrkShtReader.Worksheet.OuterXml); XMLDOMManagement.AddNamespaces(XmlNamespaceManager,XmlWrkShtDoc); XmlNodeList := XmlWrkShtDoc.SelectNodes('/x:worksheet/x:sheetData/x:row[@hidden=1]',XmlNamespaceManager); IF ISNULL(XmlNodeList) THEN EXIT; FOREACH XmlNode IN XmlNodeList DO BEGIN EVALUATE(RowNo, XmlNode.GetAttribute('r')); RowsList.Number := RowNo; RowsList.INSERT; END;
And then you can check whether the row hidden or not and use only data from visible rows:LOCAL PROCEDURE OpenXlAndGetHiddenRows(); ---------- xlBuf : TEMPORARY Record Excel Buffer; HiddenRowsList : TEMPORARY Record Integer; FileManagement : Codeunit File Management; ClientFileName : Text; ServerFileName : Text; SheetName : Text; ---------- xlBuf.RESET; xlBuf.DELETEALL; ClientFileName := FileManagement.OpenFileDialog('','',FileManagement.GetToFilterText('','*.xlsx')); IF ClientFileName = '' THEN EXIT; ServerFileName := FileManagement.UploadFileSilent(ClientFileName); SheetName := xlBuf.SelectSheetsName(ServerFileName); xlBuf.OpenBook(ServerFileName,SheetName); xlBuf.GetHiddenRowsList(HiddenRowsList); xlBuf.ReadSheet; IF xlBuf.FINDLAST THEN BEGIN MESSAGE('%1 of %2 rows are visible', xlBuf."Row No."- HiddenRowsList.COUNT, xlBuf."Row No."); IF HiddenRowsList.GET(xlBuf."Row No.") THEN MESSAGE('The last row is hidden') ELSE MESSAGE('The last row is visible'); END;
This is solution for Nav 2017, but I think can be used in Nav 2013.1 -
Just to let you guys know: FOREACH is not supported in NAV 2015 or older.
Other Solution:Name DataType Subtype Length Enumerator_l DotNet System.Collections.Generic.List`1+Enumerator.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Enumerator_l := XmlNodeList_l.GetEnumerator; WHILE Enumerator_l.MoveNext DO BEGIN XmlNode_l := Enumerator_l.Current; EVALUATE(RowNo_l, XmlNode_l.GetAttribute('r')); RowsListTmp_v.Number := RowNo_l; RowsListTmp_v.INSERT; END;
Also you have to downgrade the function AddNamespaces in the XMLDOMManagement.0 -
Slawek_Guzek wrote: »@kriki There is no option on Mibuso to delete own comment, or is there? I wanted to delete my comment once, and could not find any way to do so.
As far as I know, the only way the user can do it, is just to edit the post and remove the text in it. But the post itself remains.
The only ones that can delete posts or topics are administrators and moderators.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
As far as I know, the only way the user can do it, is just to edit the post and remove the text in it. But the post itself remains.
The only ones that can delete posts or topics are administrators and moderators.
Exactly. And the comment 325659 was not just cleared by the user, it has been physically deleted. So either someone (a forum Administrator, you?) removed it (by mistake?) or it has been deleted by some forum code bug
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I only delete posts when it is spam. When a topic is a spam topic and someone replies to it, I delete the whole topic. That is the only moment that a non-spam post is deleted.
I am not aware of a forum code bug that does that.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!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