web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Remove Line item datas

(0) ShareShare
ReportReport
Posted on by 44
Hi,
 
////
 
 
 
Please someone tell me. For this report Standard Sales - Invoice we need to remove line items in the Word report.  
 
please provide the sample/reference code in Business Central AL Technologies.
 
 
Categories:
  • Community member Profile Picture
    4 on at
    Remove Line item datas
    Sorry 
     i have more add this you can see this 
           In the above code, the RemoveLineItems method takes the file path of the Word document as input and opens it Pay My Doctor using the Open XML SDK. It iterates through each paragraph in the document and checks if it contains the text "Line Item". If it does, the paragraph is removed.
         Please note that this is a basic example, and you may need to modify the code based on the structure and formatting of your specific Word document. Additionally, make sure to add the necessary references to the Open XML SDK in your project.
  • Suggested answer
    Community member Profile Picture
    4 on at
    Remove Line item datas
    Hello , 
    To remove line items from a Word report programmatically, you can use the Microsoft Office Open XML SDK.   
    sample code snippet in C# that demonstrates how to remove line items from a Word document: 
    write this code : 
     
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;
    public void RemoveLineItems(string filePath)
    {
        using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
        {
            // Get the main document part
            MainDocumentPart mainPart = document.MainDocumentPart;
            // Get all paragraphs in the document
            var paragraphs = mainPart.Document.Body.Descendants<Paragraph>();
            foreach (var paragraph in paragraphs)
            {
                // Check if the paragraph contains line item content
                if (paragraph.InnerText.Contains("Line Item"))
                {
                    // Remove the paragraph
                    paragraph.Remove();
                }
            }
            // Save the changes
            mainPart.Document.Save();
        }
    }
     
    if any issue to contant me , i will help you 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Small and medium business | Business Central, NAV, RMS

Featured topics

Product updates

Dynamics 365 release plans